BindData to ITemplate for GridView in code behind
Posted
by tbischel
on Stack Overflow
See other posts from Stack Overflow
or by tbischel
Published on 2010-05-08T00:53:48Z
Indexed on
2010/05/08
0:58 UTC
Read the original article
Hit count: 312
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?
© Stack Overflow or respective owner