protected void filterLoan() { // 1.- Get the latest datasource allLoans = (List <LoanDTO>)ViewState["allLoans"]; // 2.- Filter by Region is value is not -1 if (DropDownSection.SelectedValue != "-1") { allLoans = BLoan.FilterBySection(allLoans, DropDownSection.SelectedItem.Text); } // 3.- Filter by loan date if it is a valid date DateTime result; if (DateTime.TryParse(TextBoxLoan.Text, out result)) { allLoans = BLoan.filterByLoanDate(allLoans, Convert.ToDateTime(TextBoxLoan.Text)); } // 4.- Filter by delivery date if it is a valid date if (DateTime.TryParse(TextBoxDelivery.Text, out result)) { allLoans = BLoan.filterByDeliveryDate(allLoans, Convert.ToDateTime(TextBoxDelivery.Text)); } // 5.- Filter by Keyword allLoans = BLoan.filterByKeyWord(allLoans, TextBoxSearch.Text); // 6.- Bind grid to datasource and save it in viewstate ViewState["filterAllLoans"] = allLoans; GridListLoans.DataSource = allLoans; GridListLoans.DataBind(); }
protected void fillLoansDTO() { // Fill the grid and save it in viewstate allLoans = DataLibrary.Loan.getAllLoanDTO(); ViewState["allLoans"] = allLoans; GridListLoans.DataSource = allLoans; GridListLoans.DataBind(); }
protected void GridListLoans_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridListLoans.PageIndex = e.NewPageIndex; // Fill the grid if (ViewState["filterAllLoans"] != null) { allLoans = (List <LoanDTO>)ViewState["filterAllLoans"]; GridListLoans.DataSource = allLoans; GridListLoans.DataBind(); } else { fillLoansDTO(); } }