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/

你可能感兴趣的:(C++,c,.net,asp.net,asp)