protected void filterBySectionAndCopy() { // 1.- Get latest datasource allBooks = (List <BookDTO>)ViewState["allBooks"]; // 2.- Filter by Section and fill Grid if (DropDownSection.SelectedValue != "-1") { allBooks = BBooks.getBookDTOBySection(allBooks, DropDownSection.SelectedItem.Text); } // 3.- Filter by copy and fill Grid if (DropDownCopies.SelectedValue != "-1") { allBooks = BBooks.getBookDTOByCopies(allBooks, Convert.ToInt32(DropDownCopies.SelectedValue)); } // 5.- Filter by author or title allBooks = BBooks.getBookDTOByAuthorOrTitle(allBooks, TextBoxSearch.Text); // 4.- Fill Grid and save it in viewState ViewState["filterBooks"] = allBooks; GridMainList.DataSource = allBooks; GridMainList.DataBind(); }
protected void fillBookDTO() { // Fill the grid with all records from BookDTO and save it in ViewState allBooks = Books.getBookDTOAll(); ViewState["allBooks"] = allBooks; GridMainList.DataSource = allBooks; GridMainList.DataBind(); }
protected void GridMainList_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridMainList.PageIndex = e.NewPageIndex; // Fill the grid if (ViewState["filterBooks"] != null) { allBooks = (List <BookDTO>)ViewState["filterBooks"]; GridMainList.DataSource = allBooks; GridMainList.DataBind(); } else { fillBookDTO(); } }