Why is my data-bound templated control so slow?
TemplateItem item = new TemplateItem();
item.DataItem = simpleContainerClass;
ITemplate template;
if (_postTemplate != null)
{
template = _postTemplate;
template.InstantiateIn(item);
this.Controls.Add(item);
}
item.DataBind();
This block of code runs once for each item in the collection of data items in the control's CreatChildControls() method. The TemplateItem class is just a container class with one property called DataItem. The last line, the DataBind() method, takes nearly .1 seconds for each item. That's obviously not acceptable.
Am I missing something here or is there just something slow about using this? I'm using v2 of .NET, by the way.