public static void dropdownbind1(string tbl, string field, DropDownList ddl, string datatext, string datatvale)
{
ddl.Items.Clear();
str = "select distinct " + field + " from " + tbl + ""
cmd = new MySqlCommand(str, Classmysql.con);
dtp = new MySqlDataAdapter(cmd);
ds = new DataSet();
dtp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
ddl.DataSource = ds;
ddl.DataTextField = datatext;
ddl.DataValueField = datatvale;
ddl.DataBind();
ddl.Items.Insert(0, "SELECT");
}
else
{
ddl.Items.Insert(0, "no details");
}
here is the example.it is general method.
}