使用javascript删除.net(c#)中的选定复选框 [英] delete selected checkboxes in .net(c#) using javascript

查看:69
本文介绍了使用javascript删除.net(c#)中的选定复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道选中所有复选框并清除所有复选框,但我需要代码来删除datagrid imn .net中的选中复选框(如果它们是5个复选框,则我删除了datagrid中的3个选中复选框)

i know the selecting all checkbox and clear all checkbox but i need a code to delete selected checkboxes in datagrid imn .net(if their are 5 checkboxes i have delete 3 selected checkboxes in datagrid)

推荐答案

方法1:
您需要做的是,一旦选择了要删除的行的复选框,就会触发回发事件,例如通过页面上的删除"按钮.

在后面的代码中,遍历网格行并获取选中了其复选框的行.相应地修改数据表/数据源.
提交对数据表/数据集所做的更改.
将此新数据表/数据集用作网格的数据源.重新绑定与此网格.

方式2:
单击复选框后,在隐藏字段中维护每行客户端的唯一键.在回发时,从此隐藏字段中获取所有行的唯一键,然后从数据集中删除这些行.将数据网格与此数据集重新绑定.
WAY 1:
What you need to do is, once you select the checkboxes of the rows that you want to delete, trigger a postback event like via Delete button on the page.

In code-behind, loop through the grid rows and get the row whose checkboxes are checked. Modify the datatable/datasource accordingly.
Commit the changes made to datatable/dataset.
Use this new datatable/dataset as a datasource of your grid. Rebind the grid with this one.

WAY 2:
On click of checkboxes, maintain the unique keys of each row client side in a hidden field. on postback, get all row unique keys from this hidden field and remove those rows from the dataset. Rebind the datagrid with this dataset.


这篇关于使用javascript删除.net(c#)中的选定复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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