How to Bind Dropdown in Gridview

Posted by Jayakumars under Regular Expressions on 5/13/2011 | Points: 10 | Views : 17678 | Status : [Member] [MVP] | Replies : 2
Hi

I need how to Bind Dropdownlist I am design Gridview and include Dropdown Control
how to bind them and selected insert,edit,delete using Dropdownlist items how will do this which method raise gridview events how will do this how to bind dropdownlist in gridview control how to using findcontrol i need most urgent

Mark as Answer if its helpful to you


Responses

Posted by: SheoNarayan on: 5/13/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Jaya,

Read this article I had written it on the similar topic http://www.dotnetfunda.com/articles/article989-dropdownlist-in-the-gridview-keeping-aspnet-forms-control-in-gridview-.aspx.

This should give you an idea how to do it.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/16/2011 [Member] Starter | Points: 25

Up
0
Down
<asp:TemplateField>
<HeaderTemplate>Emp</HeaderTemplate>
<ItemTemplate ><asp:DropDownList ID="ddl1" runat ="server" OnLoad ="ddl1_load"></asp:DropDownList></ItemTemplate>
</asp:TemplateField>

Code is:
protected void ddl1_load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select sno from student", cn);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList ddl = (DropDownList)sender;
ddl.DataSource = dt;
ddl.DataTextField = "sno";
ddl.DataValueField = "sno";
ddl.DataBind();
}



Thanks&Regards
LakshmiNarayana Nalluri.

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response