try it working perfectly
aspx page:
<asp:DropDownList ID="DropDownList1" runat="server"
ondatabound="DropDownList1_DataBound">
</asp:DropDownList>
aspx.cs
SqlConnection con = new SqlConnection("your connection string");
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select code,collegename from table", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "code";
DropDownList1.DataValueField = "collegename";
DropDownList1.DataBind();
}
protected void DropDownList1_DataBound(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if (ddl != null)
{
foreach (ListItem li in ddl.Items)
{
li.Attributes["title"] = li.Value;
}
}
}