how to bind data in DropDownList

Gow.net
Posted by Gow.net under ASP.NET category on | Points: 40 | Views : 1500
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>


 SqlConnection objcon = new SqlConnection(".......");
objcon.Open();
SqlCommand objcmd = new SqlCommand("select * from TableName", objcon);
SqlDataReader objreader = objcmd.ExecuteReader();
DropDownList1.DataSource = objreader;
// DropDownList1.DataValueField = "Columnname";
DropDownList1.DataTextField = "Columnname";
DropDownList1.DataBind();

Comments or Responses

Login to post response