如何在ASP.Net GridView控件中进行分页时保留复选框的状态 [英] how to Preserving state of Checkboxes while paging in ASP.Net GridView Control

查看:99
本文介绍了如何在ASP.Net GridView控件中进行分页时保留复选框的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void FullPost_Click(object sender,EventArgs e)

{

List< datakey> applyList = new List< datakey>();

CheckBox chkAll =(CheckBox)gvData.HeaderRow.Cells [0] .FindControl(cbxApply);

foreach( gvData.Rows中的GridViewRow行)

{

CheckBox cb =(CheckBox)row.Cells [0] .FindControl(cbxApply);

if(cb!= null)

if(cb.Checked)

applyList.Add(gvData.DataKeys [row.RowIndex]);

}



if(applyList.Count> 0)

{

gvData.DataBind( );

}



if(ApplyTest!= null)

ApplyTest();



}

protected void FullPost_Click(object sender, EventArgs e)
{
List<datakey> applyList = new List<datakey>();
CheckBox chkAll = (CheckBox)gvData.HeaderRow.Cells[0].FindControl("cbxApply");
foreach (GridViewRow row in gvData.Rows)
{
CheckBox cb = (CheckBox)row.Cells[0].FindControl("cbxApply");
if (cb != null)
if (cb.Checked)
applyList.Add(gvData.DataKeys[row.RowIndex]);
}

if (applyList.Count > 0)
{
gvData.DataBind();
}

if (ApplyTest != null)
ApplyTest();

}

推荐答案

您正在从数据库中获取复选框值,然后在OnRowDataBound上可以绑定数据。
You are getting checkbox value from Database then on OnRowDataBound you can bind data.


这篇关于如何在ASP.Net GridView控件中进行分页时保留复选框的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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