protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Header_Label.Text = "Welcome! Please select a book category."; Item_Listbox.DataSource = books; Item_Listbox.DataBind(); } }
protected void Sort_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Sort") { switch (e.CommandArgument.ToString()) { case "ASC": books.Sort(SortASC); break; case "DESC": books.Sort(SortDESC); break; } } Item_Listbox.DataSource = books; Item_Listbox.DataBind(); }
private void ShowBooks(string category) { Item_Listbox.Items.Clear(); List<string> books = null; switch(category) { case "fiction" : Header_Label.Text = "Fiction Section"; books = GetFictionBooks(); break; case "non_fiction": Header_Label.Text = "Non-Fiction Section"; books = GetNonFictionBooks(); break; case "self_help": Header_Label.Text = "Self Help Section"; books = GetSelfHelpBooks(); break; } books.Add(GetBookAddedToForm()); Item_Listbox.DataSource = books; Item_Listbox.DataBind(); }
public void Page_PreRender() { Item_Listbox.DataSource = books; Item_Listbox.DataBind(); }