大家帮我看看啊:
我在点击DataGridView时用SelectionChanged事件调用MakeDataView():
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
MakeDataView();
}
private void MakeDataView()
{
DataView dv = new DataView();
dv.Table = ds.Tables["ckd"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "ID='"+this.dataGridView2.CurrentCell.Value.ToString()+"'";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "计费日期 DESC";
this.dataGridView1.DataSource = dv;
}
其中DataView有个RowFilter过滤功能,但是运行程序时dv好像没取到值,DataGridView2没有显示任何东东...
另外:在点击左面的DataGridView时,必须要点在ID列上,否则会出错的。因为这句话: dv.RowFilter = "ID='"+this.dataGridView2.CurrentCell.Value.ToString()+"'";
大家请帮忙看看啊!谢谢!