Hi,
it displays this error Items collection cannot be modified when the DataSource property is set.?i am underlying the error.please find it.
Error:-Items collection cannot be modified when the DataSource property is set.
public void loadcompanyname()
{
DBConnection db = new DBConnection();
SqlConnection con = db.opencon();//new SqlConnection("data source=mars-104;intial catalog=marsweb.imageimpacts;integrated security=true");
SqlCommand cmd = new SqlCommand("select custid,custname from tbl_customer order by custname", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
cmb_companyname.DataSource = dt;
cmb_companyname.ValueMember = "custid";
cmb_companyname.DisplayMember = "custname";
}
cmb_companyname.Items.Insert(0, "-select one-"); }
Best,
Sudheep.