DropDownList in gridview binding at runtime

Posted by Lakn2 under ASP.NET category on | Points: 40 | Views : 6105
add one dropdownlist in templatefield
<ItemTemplate ><asp:DropDownList ID="ddl1" runat ="server" OnLoad ="ddl1_load"></asp:DropDownList></ItemTemplate>
Code is:
protected void ddl1_load(object sender, EventArgs e)
SqlDataAdapter da = new SqlDataAdapter("select sno from student", cn);
DataTable dt = new DataTable();
DropDownList ddl = (DropDownList)sender;
ddl.DataSource = dt;
ddl.DataTextField = "sno";
ddl.DataValueField = "sno";

Comments or Responses

Posted by: T.saravanan on: 5/2/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi Lakshmi Narayana Nalluri,

Good one.Kindly post your code inside the code tag.
Posted by: Vinaym on: 5/6/2011 Level:Starter | Status: [Member] | Points: 10
Good one

Login to post response