Exemple #1
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void InitData()
        {
            //获取当前管理员角色
            IAccountRoleService accountRole     = IoC.Resolve <IAccountRoleService>();
            List <AccountRole>  accountRoleList = accountRole.GetAccountRoleList(userId);


            //获取角色列表
            IRoleService roleService            = IoC.Resolve <IRoleService>();
            List <Ytg.BasicModel.Role> roleList = roleService.GetAll().ToList();

            if (roleList != null && roleList.Count > 0)
            {
                List <AccountRoleModel> dataSource = new List <AccountRoleModel>();
                foreach (var item in roleList)
                {
                    AccountRoleModel model = new AccountRoleModel();
                    model.RoleId    = item.Id;
                    model.RoleName  = item.Name;
                    model.Descript  = item.Descript;
                    model.IsChecked = false;
                    if (null != accountRoleList.Where(m => m.RoleId == item.Id).FirstOrDefault())
                    {
                        model.IsChecked = true;
                    }
                    dataSource.Add(model);
                }

                this.repList.DataSource = dataSource;
                this.repList.DataBind();
            }
        }
Exemple #2
0
        protected void repList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            AccountRoleModel model = (AccountRoleModel)e.Item.DataItem;

            ((CheckBox)e.Item.FindControl("cBox")).Checked = model.IsChecked;
        }