Hi friends,
How to show dropdownlist in gridview on click of edit button
How to bind dropdownlist with data in gridview
plz help me
How to show dropdownlist in gridview on click of edit button
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Priya LingeRank #785 · 2.9K reputationPosted Aug 1, 2011, 9:59 PM EDT
Code for binding GridView.
string query = "select * from Customer";
con.Open();
cmd = new SqlCommand(query, con);
da = new SqlDataAdapter(cmd);
myDataSet = new DataSet();
da.Fill(myDataSet);
GridView1.DataSource = myDataSet;
GridView1.DataBind();
con.Close();
On Edit Button Click. code for Dropdownlist.
cmd = new SqlCommand("select * from CustomerData", con);
da = new SqlDataAdapter(cmd);
myDataSet = new DataSet();
da.Fill(myDataSet);
DropDownList drdList;
foreach (GridViewRow grdRow in GridView1.Rows)
{
drdList = (DropDownList)(GridView1.Rows[grdRow.RowIndex].Cells[1].FindControl("DropDownList1"));
drdList.DataSource = myDataSet;
//drdList.DataValueField = "ID";
drdList.DataTextField = "Name";
drdList.DataBind();
}
Please check below link.Which help you to binding code.
http://programming.top54u.com/post/ASP-Net-GridView-DropDownList-DataSource-and-DataBinding.aspx
Hope this will help you.
Thanks.