//EnableSortingAndPagingCallbacks to minimize postbacks? private void SortGridView(string sortExpression, string direction) { GridBAL booksLogic = new GridBAL(); //DataView myDataView = new DataView(booksLogic.GetData()); DataView myDataView = new DataView(); if (ViewState["username"].ToString() == "") { if (Convert.ToByte(ViewState["filter"]) == 1) { myDataView = booksLogic.GetData(Convert.ToByte(ViewState["filter"])).AsDataView(); } else { myDataView = booksLogic.GetData().AsDataView(); } } else { myDataView = booksLogic.GetDataByUsername(ViewState["username"].ToString()).AsDataView(); } myDataView.Sort = sortExpression + direction; BooksGrid.DataSource = myDataView; BooksGrid.DataBind(); }
protected void TakenBooks_Click(object sender, EventArgs e) { ViewState["filter"] = 0; if (Session["email"] != null) { ViewState["username"] = (string)(Session["email"]); } else { ViewState["username"] = ""; } //ViewState["username"] = "******"; GridBAL booksLogic = new GridBAL(); if (ViewState["username"].ToString() != "") { BooksGrid.DataSource = booksLogic.GetDataByUsername(ViewState["username"].ToString()); BooksGrid.DataBind(); } else { TestLabel.Text = "You are not logged in"; } }