点击一个按钮时,再在AspxGridView里找checkbox,怎么找呢?这样就会报未将对象引用到对象的实例protected void btnSave_Click(object sender, EventArgs e)
{
for (int i = 0; i < G1.VisibleRowCount; i++)
{
CheckBox chkselect = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[2], "chkSelect") as CheckBox;
CheckBox chkupdate = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[3], "chkUpdate") as CheckBox;
CheckBox chkDelete = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[4], "chkDelete") as CheckBox;
int moduleID = int.Parse(G1.GetRowValues(i, "pub_dict_value_id").ToString());
ListBase<PubRoleAuth> lst= PubRoleAuthProvider.FindBySqlWhere(" role_id=12 and module_id=" + moduleID + "");
if (lst.Count > 0)
{
PubRoleAuth roleauth = new PubRoleAuth();
roleauth.Role_id = 12;
roleauth.Module_id = moduleID;
roleauth.Is_view = chkselect.Checked;
roleauth.Is_edit = chkupdate.Checked;
roleauth.Is_delete = chkDelete.Checked;
if (PubRoleAuthProvider.Update(roleauth))
{
ShowMessage("dasfad", false);
this.ShowMessage("修改权限成功!",false);
}
}
else
{ }
}
}
{
for (int i = 0; i < G1.VisibleRowCount; i++)
{
CheckBox chkselect = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[2], "chkSelect") as CheckBox;
CheckBox chkupdate = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[3], "chkUpdate") as CheckBox;
CheckBox chkDelete = G1.FindRowCellTemplateControl(i, (GridViewDataColumn)G1.Columns[4], "chkDelete") as CheckBox;
int moduleID = int.Parse(G1.GetRowValues(i, "pub_dict_value_id").ToString());
ListBase<PubRoleAuth> lst= PubRoleAuthProvider.FindBySqlWhere(" role_id=12 and module_id=" + moduleID + "");
if (lst.Count > 0)
{
PubRoleAuth roleauth = new PubRoleAuth();
roleauth.Role_id = 12;
roleauth.Module_id = moduleID;
roleauth.Is_view = chkselect.Checked;
roleauth.Is_edit = chkupdate.Checked;
roleauth.Is_delete = chkDelete.Checked;
if (PubRoleAuthProvider.Update(roleauth))
{
ShowMessage("dasfad", false);
this.ShowMessage("修改权限成功!",false);
}
}
else
{ }
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货