Hi friends,
How to show dropdownlist in gridview on click of edit button
How to bind dropdownlist with data in gridview
plz help me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priya LingePosted Aug 2, 2011, 1:59 AM
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.