Thursday, 19 January 2012

How to Bind Data of a Field To DropDownList in C# Logic:

Make Design Your Page As Follows:


In Event FillComboboxes:
conn.Open();
string str = "select "+Field+"  from "+table+"";
da = new SqlDataAdapter(str, conn);
da.Fill(ds);
ddl.DataSource = ds;
ddl.DataValueField = Field;
ddl.DataBind();
conn.Close();
In Page_Load :
FillComboboxes("Customer", "CustName", DropDownList1);
FillComboboxes("Customer", "CustID", DropDownList2);

No comments:

Post a Comment