这样呢?
Row.BeginEdit();
Row.Delete();
Row.EndEdit();
Row.AcceptChanges();
Row.BeginEdit();
Row.Delete();
Row.EndEdit();
Row.AcceptChanges();
解决方案 »
- C#分割字符串
- 如何用按钮通过javascript控制div的滚动
- 采用哪个控件?
- 怎么讲listbox的selectvalue与播放器的filename绑定起来
- 请问如何将文本或者图片拷贝至剪贴板?
- 关于网站在线用户在线检测的实现
- DataGrid中怎样实现:如果是管理员,'密码'字段显示的是真实的值(密码);如果是普通用户,显示的是'6个*'(常量符号)
- datalist控件的问题
- 疑难:ASP.NET里面如何调用Word的拼写检查控件,来检查网页的一个文本区域?
- help
- 如何判断DataSet里某个表是否有内容
- 如何把 string[] jobs = Request.Form.GetValues("seljobfamily") 存入数据库?
方法试试看
private void DemonstrateDeleteRow(){
// Create a simple DataTable with two columns and ten rows.
DataTable myTable = new DataTable("myTable");
DataColumn c1 = new DataColumn("id",Type.GetType("System.Int32"));
c1.AutoIncrement=true;
DataColumn c2 = new DataColumn("item", Type.GetType("System.String"));
myTable.Columns.Add(c1);
myTable.Columns.Add(c2);
// Add ten rows.
DataRow newRow;
for(int i = 0; i <10; i++){
newRow = myTable.NewRow();
newRow["item"] = "Item " + i;
myTable.Rows.Add(newRow);
}
myTable.AcceptChanges();
// Create a DataView with the table.
DataRowCollection rc = myTable.Rows;
rc[0].Delete();
rc[2].Delete();
rc[3].Delete();
rc[5].Delete();
Console.WriteLine(rc[3].RowState.ToString());
// Reject changes on one deletion.
rc[3].RejectChanges();
// Change the value of the column so it stands out.
rc[3]["item"] = "Deleted, Undeleted, Edited";
// Accept changes on others.
myTable.AcceptChanges();
// Print the remaining row values.
foreach(DataRow r in myTable.Rows){
Console.WriteLine(r[0] + "\t" + r[1]);
}
}