且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在按钮单击时删除已检查的记录

更新时间:2022-12-19 16:25:08

看看这个..

从datgridview和数据库访问中删除行 [ ^ ]


我希望这能帮到你!

  int  index = GridView1.SelectedIndex; 
gv.DeleteRow(index); // 使用gridview实例的deleterow方法(gv是你的gridview实例)



从数据表中删除

 DataTable dt =  new  DataTable();  //  您的数据表实例 
// index = dt.Rows.IndexOf(dr); //获取指定行的索引
dt.Rows [index] .Delete(); // 删除行



更多方法:

 dt.Rows.RemoveAt(index );  //  如果您知道行索引 
// dt.Rows.Remove(dr); //如果你有指定行的实例
,请使用它>



一些帮助你的链接:

如何:删除DataTable中的行

GridView删除行

GridView删除,确认

GridView.DeleteRow方法


I have Grid like this

Delete(chkbox col) name address mobile
raj mumbai 9999999999
sri delhi 8888888888

i have ten records in grid.
I want to delete records of checked checkbox , how can i achieve this task?.

thanks in advance.

Have a look at this one..
Delete rows from datgridview and database access[^]


i hope this help you!
int index=GridView1.SelectedIndex;
gv.DeleteRow(index);// use deleterow method of gridview instance (gv is your gridview instance)


Delete from datatable

DataTable dt = new DataTable();// your datatable instance
//index=dt.Rows.IndexOf(dr); //get index of specified row
dt.Rows[index].Delete();//delete the row


more ways :

dt.Rows.RemoveAt(index);//use this if you know index of row
//dt.Rows.Remove(dr);//use this if you have instance of specified row



some link to help you:
How to: Delete Rows in a DataTable
GridView Delete Row
GridView Delete, with Confirmation
GridView.DeleteRow Method