private void RenderGrid() { var categoryBll = new CategoryBll(); GridCategories.DataSource = categoryBll.GetCategories(); GridCategories.DataBind(); }
protected void search_OnClick(object sender, EventArgs e) { var categoryBll = new CategoryBll(); try { GridCategories.DataSource = categoryBll.SearchCategories(searchTerm.Text); GridCategories.DataBind(); } catch (Exception exception) { error.InnerText = exception.Message; } }
protected void orderByName_OnClick(object sender, EventArgs e) { var categoryBll = new CategoryBll(); var orderName = (string)Session["orderName"]; var categories = categoryBll.SearchCategories(searchTerm.Text); if (orderName == "desc") { orderName = "asc"; categories = categories.OrderBy(p => p.Name).ToList(); } else { orderName = "desc"; categories = categories.OrderByDescending(p => p.Name).ToList(); } Session["orderName"] = orderName; GridCategories.DataSource = categories; GridCategories.DataBind(); }