C#Winforms解决方案 - Visual Studio 2015专业版。
大家好!当我调试我的应用程序时,打开我的表单,单击comboBoxCurso(父组合框)并选择英语,例如,然后单击DataGridView中的comboBoxModulo(子组合框),我收到错误说:
“System.Data.dll中发生了'System.Data.EvaluateException'类型的未处理异常 附加信息:无法找到[英文]栏目。“
private void Alunos_Load(object sender, EventArgs e)
{
this.tbl_cursosTableAdapter.Fill(this.bremingtonDataSet.tbl_cursos);
this.tbl_modulosTableAdapter.Fill(this.bremingtonDataSet.tbl_modulos);
this.tbl_turmasTableAdapter.Fill(this.bremingtonDataSet.tbl_turmas);
this.tbl_alunosTableAdapter.Fill(this.bremingtonDataSet.tbl_alunos);
this.tbl_alunos_subTableAdapter.Fill(this.bremingtonDataSet.tbl_alunos_sub);
DataView dv = new DataView(bremingtonDataSet.Tables["tbl_modulos"]);
filteredModulosBS.DataSource = dv;
}
private void tbl_alunos_subDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if (e.ColumnIndex == comboBoxModulo.Index)
{
DataGridViewComboBoxCell dgcb = (DataGridViewComboBoxCell)tbl_alunos_subDataGridView[e.ColumnIndex, e.RowIndex];
dgcb.DataSource = filteredModulosBS;
**Error =====> this.filteredModulosBS.Filter = "Código = "+ this.tbl_alunos_subDataGridView[e.ColumnIndex - 1, e.RowIndex].Value.ToString(); <===== Error**
}
}
private void tbl_alunos_subDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == this.comboBoxModulo.Index)
{
DataGridViewComboBoxCell dgcb = (DataGridViewComboBoxCell)tbl_alunos_subDataGridView[e.ColumnIndex, e.RowIndex];
dgcb.DataSource = tblmodulosBindingSource;
this.filteredModulosBS.RemoveFilter();
}
}
任何人都可以告诉我如何纠正这行代码?非常感谢您的时间和帮助。我真的很感激!
答案 0 :(得分:0)
您需要将过滤条件参数包装在单引号'
中。
this.filteredModulosBS.Filter = "Código = '" + this.tbl_alunos_subDataGridView[e.ColumnIndex - 1, e.RowIndex].Value.ToString() + "'";