I have a table that populate Combobox1 and Combobox1 should populate Combobox2 and this is where the problem is. That's the exception i'm getting
The multi-part identifier "System.Data.DataRowView" could not be bound.
Code :
private void frm2_Load(object sender, EventArgs e)
{
//Populate Combobox1
SqlDataAdapter da = new SqlDataAdapter("SELECT CategoryID, Name FROM Categories", clsMain.con);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox1.DataSource = ds.Tables[0];
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "CategoryID";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//populate Combobox2
SqlDataAdapter da = new SqlDataAdapter("SELECT SubCategoryID, Name FROM SubCategories WHERE CategoryID=" + comboBox1.SelectedValue, clsMain.con);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox2.DataSource = ds.Tables[0];
comboBox2.DisplayMember = "Name";
comboBox2.ValueMember = "SubCategoryID";
}