Problem with dropdown in gridview

How to add an incremental list to a gridview and how to add a data source to a dropdown?

For instance:

I have a gridview with 5 colomns c1, c2, c3, c4, c5. Here I only want to add the dropdown c1 and c2 What is the procedure for doing this work?

Note: vs2008, asp.net with c #

0


a source to share


1 answer


You can edit the columns in the GridView and set these two TemplateColumns and then put a DropDownList named DropDownList1 in the TemplateColumn. Then, as Hunter says, using the DataBound event to bind to the dataset like so:



DropDownList list = e.Item.FindControl("DropDownList1");
list.DataSource = < your DataSet here>;
list.DataValueField = "code";
list.DataTextField = "description";
list.DataBind();

      

0


a source







All Articles