使用一个表过滤带有两个组合框的datagridview

时间:2016-06-04 08:16:05

标签: c# sql

我在网上搜索但没有结果,没有任何东西给我我想要的东西,都有多个表,我正在使用一个有两个组合框列的datagridview第一列有数据源isfsectionsbindingsource,value member = isfsectionName和选中的值properties.i中的parentISfkey包含一个包含父ID和子ID的表。 表ISFsections:ISFsectionId,ISFsectionName,ParentISFkey

private void dataGridView2_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {


            for (int i = 0; i < iSFsectionsBindingSource.Count; i++)
            {
                if (e.ColumnIndex == 4 && dataGridView2.Rows[i].Cells["Column11"].Value == null)
                {
                    MessageBox.Show("Choose 1st combobox value");
                }

                else
                {
                    cnn.Open();
                    DataSet ds = new DataSet();
                    SqlDataAdapter dabank = new SqlDataAdapter();
                    SqlCommand cmd10 = cnn.CreateCommand();
                    cmd10.CommandText = "select ISfsectionId, isfsectionName from ISFsections where ISfsectionId = @ParentISFkey";
                    cmd10.Parameters.AddWithValue("@ParentISFkey", dataGridView2.Rows[i].Cells["Column11"].Value);
                    cmd10.Connection = cnn;
                    cmd10.ExecuteNonQuery();
                    dabank.Fill(ds, "isfsectionName");

                    dataGridView2.Rows[i].Cells["Column23"].DataGridView.DataSource = ds;
                }

            }
            }

现在当点击第一个组合框时,它告诉我需要参数&#39; @ ParentISFkey&#39;,这是未提供的。我正在使用它有关这个的任何帮助

0 个答案:

没有答案