BindData to ITemplate for GridView in code behind
- by tbischel
How do I programmatically bind data to a custom item template column for a GridView? So far, I've done something similar to this:
TemplateField foo = new TemplateField();
foo.ItemTemplate = new bar();
this.GridView1.Columns.Add(foo);
where bar is like this:
public class bar : ITemplate
{
public bar()
{
}
public void InstantiateIn(Control container)
{
DropDownList ddl = new DropDownList();
container.Controls.Add(ddl);
}
}
(the actual dropdownlist is populated)
But ITemplate doesn't contain any kind of data binding properties to implement, and the TemplateField class doesn't seem to have any either...
What do I do?