asp.net GridView模板后台打开页面为默认选中状态,复选框动态默认选中

选择一条信息,然后查出这条信息的值,比如值为,555,666,999,然后GridView模板里有另外的checkBox,其中有值为555,666,999的值,则选中值为555,666,999的复选框

#region 在更改部门权限选中状态时激发

protected void ckbBMQX_CheckedChanged(object sender, EventArgs e)
{
Model.department.DeptKey modelDeptKey = new Model.department.DeptKey();

foreach (GridViewRow row in this.grwBMQX.Rows)
{
if (((CheckBox)(row.FindControl("ckbBMQX"))).Checked == true)
{
modelDeptKey.Cdlx = ((Label)(row.FindControl("lblViewBMQX"))).Text.ToString();
}
}

BLL.deptInfo.DeptKey bllSelectBMQX = new BLL.deptInfo.DeptKey();

string strGLSJ_Temp = bllSelectBMQX.get_menuCaption_BMDM_SM(glbm, modelDeptKey.Cdlx);

string[] strGLSJ = strGLSJ_Temp.Split(',');//取出dzjc_bmqx中glsj字段集合并由","分割开

foreach (GridViewRow row in this.gvwBMMC.Rows)
{
modelDeptKey.Glbm = ((Label)(row.FindControl("lblViewBMDM"))).Text.ToString();//取出当前 部门代码字段

foreach (string strGLSJ_Foreach in strGLSJ)//遍历strGLSJ数组
{
if (strGLSJ_Foreach.Equals(modelDeptKey.Glbm))//对比strGLSJ数组里所有值是否和当前取出的部门代码字段相同
{
((CheckBox)(row.FindControl("ckbBMMC"))).Checked = true;//相同则设置当前checkBox为选中
}
}
}
//Response.Write(Session["sessionUserName"]);//取出session
}

#endregion


黑色头发:http://heisetoufa.iteye.com/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值