Ejemplo n.º 1
0
 private void PageInit()
 {
     if (Id > 0)
     {
         txtuserName.Text      = AdminUserBiz.GetUserNameById(Id);
         txtuserName.BackColor = System.Drawing.Color.BlanchedAlmond;
         txtuserName.ReadOnly  = true;
     }
 }
        private void PageInit()
        {
            rpt_UserRole.DataSource = MenuBiz.GetMenuList(0);
            rpt_UserRole.DataBind();

            if (UserId != 0)
            {
                lbl_Permissions.Text = AdminUserUserBiz.GetUserNameById(UserId);
                string Permissions = AdminUserUserBiz.GetPermissionsByUserID(UserId);
                if (Permissions != string.Empty)
                {
                    foreach (RepeaterItem item in rpt_UserRole.Items)
                    {
                        Repeater rptRole   = (Repeater)item.FindControl("rptRole");   //子菜单repeater
                        CheckBox CheckBox1 = (CheckBox)item.FindControl("CheckBox1"); //大类别前的CheckBox
                        Label    lbl_id    = (Label)item.FindControl("lbl_id");       //大类别ID
                        if (Permissions.IndexOf("," + lbl_id.Text + ",") != -1)
                        {                                                             //如果存在此选项则选中复选框
                            CheckBox1.Checked = true;
                        }

                        #region 二级分类
                        foreach (RepeaterItem itemRole in rptRole.Items)
                        {
                            CheckBox    cbkrowone = (CheckBox)itemRole.FindControl("cbkrowone"); //子菜单前的CheckBox
                            HiddenField hfid      = (HiddenField)itemRole.FindControl("hfid");   //子菜单的ID
                            if (Permissions.IndexOf("," + hfid.Value + ",") != -1)
                            {                                                                    //如果存在此选项则选中复选框
                                cbkrowone.Checked = true;
                            }
                        }
                        #endregion
                    }

                    if (Permissions.IndexOf("Permissions_s1") != -1)
                    {
                        cbk_Permissions.Checked = true;
                    }
                }
            }
        }