Exemplo n.º 1
0
        protected void gvUsers_Sorting(object sender, GridViewSortEventArgs e)
        {
            //re-run the query, use linq to sort the objects based on the arg.
            //perform a search using the constraints given
            //you could have this saved in Session, rather than requerying your datastore
            List <MDBUser> users = MDBUser.GetAllUsers();

            if (users != null)
            {
                var param          = Expression.Parameter(typeof(MDBUser), e.SortExpression);
                var sortExpression = Expression.Lambda <Func <MDBUser, object> >(Expression.Convert(Expression.Property(param, e.SortExpression), typeof(object)), param);

                if (GridViewSortDirection == SortDirection.Ascending)
                {
                    gvUsers.DataSource    = users.AsQueryable <MDBUser>().OrderBy(sortExpression);
                    GridViewSortDirection = SortDirection.Descending;
                }
                else
                {
                    gvUsers.DataSource    = users.AsQueryable <MDBUser>().OrderByDescending(sortExpression);
                    GridViewSortDirection = SortDirection.Ascending;
                }

                gvUsers.DataBind();
            }
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         gvUsers.DataSource = MDBUser.GetAllUsers();
         gvUsers.DataBind();
     }
 }
Exemplo n.º 3
0
        private void BindVisibleToUsers(string visibleToUsers = "", bool enabled = true)
        {
            CheckBoxList chkbxlstVisibleToUsers = ((CheckBoxList)dvPreset.FindControl("chkbxlstVisibleToUsers"));

            foreach (MDBUser u in MDBUser.GetAllUsers())
            {
                ListItem li = new ListItem
                {
                    Text     = u.FullName,
                    Value    = u.UserName,
                    Enabled  = enabled,
                    Selected = (visibleToUsers == "" ? false : visibleToUsers.Contains(u.UserName))
                };
                chkbxlstVisibleToUsers.Items.Add(li);
            }
        }