I am trying to filter a 2nd Combobox based on the selected value of the 1st Comboxbox. For example, when the user choses "BMW" from the cbxmanufacturer control, I need the cbxModel control to display all models associated to "BMW". I am almost there but I get an error "Cannot find Column[System.Data.DataRowView", please help!

My code is

private void NewVehicleDetails_Load(object sender, EventArgs e)

            connection.ConnectionString = "";

            command.CommandText = "SELECT * FROM Vehicle_Model; " +
                                  "SELECT DISTINCT ManufacturerName FROM Vehicle_Manufacturer;";
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            adapter.SelectCommand.Connection = connection;
            cbxManufacturer.DisplayMember = "ManufacturerName";
            cbxManufacturer.ValueMember = "ManufacturerID";
            cbxManufacturer.DataSource = dSet.Tables[1];

            cbxModel.DisplayMember = "ModelName";
            cbxModel.ValueMember = "ModelID";
            cbxModel.DataSource = dSet.Tables[0];
        private void cbxManufacturer_SelectionChangeCommitted(object sender, EventArgs e)
            string comb1 = ((System.Windows.Forms.ListControl)(cbxManufacturer)).SelectedValue.ToString();
            string expr = "ManufacturerID = " + comb1;
            DataRow[] dRows = dSet.Tables[0].Select(expr); // Errors here

            for (int i = 0; i < dRows.Length; i++)

If you run the query for "ManufacturerID = " + comb1 in SQL Server Management Studio, can you get the result successfully?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.