protected void btnsubmit_Click(object sender, EventArgs e) { string str = ","; if (UserId > 0) { foreach (RepeaterItem item in rpt_UserRole.Items) { CheckBox CheckBox1 = (CheckBox)item.FindControl("CheckBox1"); //大类别前的CheckBox Label lbl_id = (Label)item.FindControl("lbl_id"); //大类别id if (CheckBox1.Checked == true) { //如果复选框有选中,添加权限 str += lbl_id.Text + ","; } #region 二级分类 Repeater rptRole = (Repeater)item.FindControl("rptRole"); foreach (RepeaterItem itemRole in rptRole.Items) { CheckBox cbkrowone = (CheckBox)itemRole.FindControl("cbkrowone"); //子菜单前的CheckBox HiddenField hfid = (HiddenField)itemRole.FindControl("hfid"); //子菜单的ID if (cbkrowone.Checked == true) { str += hfid.Value + ","; //添加到权限(子菜单一定要勾选) } } #endregion } if (cbk_Permissions.Checked == true) { str += "Permissions_s1,"; } if (AdminUserUserBiz.UpdateUserRoleByUserID(str, UserId) > 0) { base.ErrorMsg("提交成功!", Request.Url.ToString(), 1); } else { base.ErrorMsg("提交失败!", Request.Url.ToString(), 0); } } }