如何在复选框上删除gridview中的行 [英] how to delete row from gridview on checkbox checked
本文介绍了如何在复选框上删除gridview中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview,其中包含一个复选框。现在我想删除所选复选框上的行。我怎么能这样做?
i have a gridview which include a column which is checkbox . now i want to delete rows on the selected checkboxes's. how can i do this?
推荐答案
参考这个如何使用Asp.Net上的Checkbox删除Gridview中的行 [ ^ ]
你可以这样做 -
You can do this --
foreach(GridViewRow gvrow in gvDetails.Rows) // iterate all the rows
{
CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect"); // find the checkbox control in that row
if (chk != null & chk.Checked) // check if checkbox if checked
{
string Id = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString() + ','; // get the Id or any value using checked row in grid
// fire delete query here based on Id
}
}
<此处点击删除查询br $> b $ b
-KR
-KR
这篇关于如何在复选框上删除gridview中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文