datagridview checkbox 全选后,如何删除所选?
很多删除代码都不能从物理上删除数据库里的数据,有的根本没反映,如:
dataGridView1.Rows.RemoveAt(pIntRowIndex);
((DataRowView)dataGridView1.SelectedRows[0].DataBoundItem).Row.Delete();
ds.Tables[strTable].Rows[rowIndex].Delete();
都不能真正删除...
SQL 2005
SQL 2000 数据库分别如何删除?
[解决办法]
我的DataGridVIew第一列 是ComboBox 第二列是 编号
- C# code
for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { if (this.dataGridView1.Rows[i].Cells["Column1"].Value == null) { continue; } if ((bool)this.dataGridView1.Rows[i].Cells["Column1"].Value) { //这个地方写删除 //我这里是用的3层 //pgB.Delete(Convert.ToInt32(dataGridView1.Rows[i].Cells["Column2"].Value.ToString())); //dataGridView1.Rows[i].Cells["Column2"].Value.ToString())是得到编号 根据编号删 //你自己想根据什么删就什么删 最好唯一的 } }