How to Use DropDownList Controls

 Design View

<%@ page language="C#" autoeventwireup="true" codefile="Default.aspx.cs" inherits="_Default" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
    <title>Untitled Page</title>

</
head>
<
body>
    <form id="form1" runat="server">
    <div style="height: 357px; width: 527px; background-color: #333333">
        &nbsp;&nbsp;&nbsp;
        <br />
        <br />
        <br />
        <br />
        <br />
      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:dropdownlist id="DropDownList1" runat="server" height="21px" width="259px">

</
asp:dropdownlist>
    </div>
    </form>

</
body>
</
html>

Code Behind

using System;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Data;
using
System.Data.SqlClient;

public
partial class _Default : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=DHRAMVEER-PC\\SQLEXPRESS;Initial Catalog=iframe;Integrated
Security=True"
);
    protected void Page_Load(object sender, EventArgs e)
    {
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select distinct name from info ", con);
        DataTable dt = new DataTable();
        da.Fill(dt);
        con.Close();
        DropDownList1.DataSource = dt;
        DropDownList1.DataTextField = "name";
        DropDownList1.DataBind();
    }
}