protected void fillUsersGrid() { // Fill the grid and save it in viewState allUsers = BUsers.getAllUserDTO(); ViewState["allUsers"] = allUsers; GridMainDetailsUser.DataSource = allUsers; GridMainDetailsUser.DataBind(); }
protected void GridMainDetailsUser_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridMainDetailsUser.PageIndex = e.NewPageIndex; if (ViewState["filterUsers"] != null) { allUsers = (List <UserDTO>)ViewState["filterUsers"]; GridMainDetailsUser.DataSource = allUsers; GridMainDetailsUser.DataBind(); } else { fillUsersGrid(); } }
protected void filterUsers() { // 1.- Get the last data source from viewstate allUsers = (List <UserDTO>)ViewState["allUsers"]; // 2.- Filter by Region if value is not -1 if (DropDownRegion.SelectedValue != "-1") { allUsers = BUsers.filterByRegion(allUsers, DropDownRegion.SelectedItem.Text); } // 3.- Filter by KeyWord allUsers = BUsers.filterByNameLastNameDni(allUsers, TextBoxSearch.Text); // 4.- Bind grid and save it in viewstate ViewState["filterUsers"] = allUsers; GridMainDetailsUser.DataSource = allUsers; GridMainDetailsUser.DataBind(); }