how to bind data in ListItem in dropdownlist

Gow.net
Posted by Gow.net under ASP.NET category on | Points: 40 | Views : 1550
 <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();
objreader.Read();
{
DropDownList1.Items.Add(new ListItem(objreader.GetString(1)));
}

Comments or Responses

Login to post response