仅获取GridView中复选框的选择值 [英] Get only select values of the Checkbox in GridView

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

问题描述

GridView的第一列具有CheckBox.
GridView的页面大小为5的分页.

在GridView中有12条记录.所以Gridview显示3页,现在我仅在第一页中选中2个复选框,在第二页中选中3个复选框,在第三页中仅选中1个复选框.

现在在Button click事件中,我正在编写代码

The first column of a GridView is having CheckBox.
GridView is having paging of page size =5.

IThere are 12 records in a GridView. So Gridview shows 3 pages Now i check only 2 checkboxes in first page and 3 checkboxes in second page and only 1 checkbox in third page.

Now in Button click event i am writing the code

string DID= "";
 foreach (GridViewRow gvrow in gvFiles.Rows)
{
            CheckBox chk = new CheckBox();
            chk = (CheckBox)gvrow.FindControl("chkSelect");
            if (chk.Checked)
            {
               if (DID== "")
DID= gvFiles.DataKeys[gvrow.RowIndex].Values["DocumentID"].ToString();
             else
             DID= DID+ "," + gvFiles.DataKeys[gvrow.RowIndex].Values["DocumentID"].ToString();
            }
}
return DID;


仅显示网格第一页中选中的行.不会捕获Gridview其他页面中选中的行.

我可以获取以下代码吗?.在这里,我只能获取GridView所有页面中的选中行.

谢谢,
yashoda


Only the checked rows for the first page of the grid is showing. the checked rows in the other pages of Gridview are not captured.

Can i get the code for the following.. where i can get only the checked rows in all the pages of a GridView.

Thankyou,
yashoda

推荐答案

请参见维护选定复选框处于不同状态的状态GridView内的页面 [ ^ ]


您没有得到其他检查记录,因为每次单击页码时它都会加载,并且检查记录的状态会丢失.

您可以通过此方法找到解决方案.

解决方案 [
you are not getting the other checked records because it loads everytime you click on page numbers and the state of checked records gets lost.

you can find solution by this..

Solution[^]

Its just like you select mails in Gmail...think about it.. :)


这篇关于仅获取GridView中复选框的选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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