insert DropDownList and TextField in Gridview
Posted
by userk
on Stack Overflow
See other posts from Stack Overflow
or by userk
Published on 2010-05-24T22:15:06Z
Indexed on
2010/05/24
22:21 UTC
Read the original article
Hit count: 191
HI,I need to create a GridView which DataSource is an object. Depending on the object I may need some columns with DropDownLists or TextFields (but not all rows)
As I don't know the number or columns, they have to be dynamic. I found this solution:
TemplateField t = new TemplateField();
t.HeaderTemplate = new GridViewTemplate("header", "title");
t.ItemTemplate = new GridViewTemplate("combobox", "val");
GridView1.Columns.Add(t);
GridView1.DataSource = ds;
GridView1.DataBind();
Where GridViewTemplate extends ITemplate.
This didn't work for me, it fills all rows of a column and I had no way to control witch DropDownList and TextFields need to be created (object info).
All the DropDownLists need to have an ID also only known by the object.
There are some way I can do this?
© Stack Overflow or respective owner