Reputation: 7176
I have a gridview that I am dynamically creating and populating.
GridView myGrid = new GridView();
myGrid.Showfooter = true;
myGrid.Columns.Add(new BoundField() { HeaderText = "Serial #", DataField = "serial_number" });
...
...
...
myGrid.DataSource = myDS;
myGrid.DataBind();
My problem is that I'm having problems figuring out how to add a templatecolumn with a dropdownlist in it. Any ideas?
Thanks and Happy Holidays.
Upvotes: 0
Views: 2786
Reputation: 17680
To add a dropdownlist programmatically via a templatefield you first need to create a class that implements ITemplate and pass that to the ItemTemplate property of the templatefield.
a clear example is stated here
although the example doesn't use a dropdownlist, the concept is essentially the same.
Upvotes: 3