如何在GridView中删除选中的复选框行 [英] How to delete selected checkbox row in gridview

查看:105
本文介绍了如何在GridView中删除选中的复选框行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gridview中删除选中的复选框行

How to delete selected checkbox row in gridview

推荐答案

您需要使用.FindControl和唯一值来删除垂直行.
这是一个粗略的主意

为每个datagridview行
You need to use .FindControl and a unique value to delete perticular row.
here is rough idea

for each datagridview row
{
   checkbox chk = new checkbox();
   chk = gridviewrow.findcontrol("chkbox");
   if(chk.checked)
   {
      //delete row with unique value  
   }
   chk = null;
}


尝试一下..

try this..

//On Check Changed event..

CheckBox chk = (CheckBox)(sender);
GridViewRow grdrow = (GridViewRow)(chk.Parent.Parent.Parent);
int index = grdrow.RowIndex;

GridView1.Rows.RemoveAt(index);



希望这对您有帮助.



hope this helps..


单击事件,首先使用foreach将所有未选择的记录放入数据集中,然后将该数据集绑定到网格.如果您无法使用此方法找到解决方案,则可以详细告诉我您的问题.
at click event, using foreach first put all unselected records in dataset and bind that dataset to grid after that. if you can''t find solution using this then you can tell me your problem in detail.


这篇关于如何在GridView中删除选中的复选框行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆