protected void Page_Load(object sender, EventArgs e) { if (Session["admin"].ToString() == "1") { DataTable dt = new DataTable(); DataRow row; dt.Columns.Add("ID"); dt.Columns.Add("Username"); dt.Columns.Add("Name"); dt.Columns.Add("Address"); dt.Columns.Add("Email"); dt.Columns.Add("Phone"); for (int i = 0; i < Dal.GetAllUserData().Count; i++) { row = dt.NewRow(); row["ID"] = Dal.GetAllUserData()[i].UserID; row["Username"] = Dal.GetAllUserData()[i].Username; row["Name"] = Dal.GetAllUserData()[i].Fullname; row["Address"] = Dal.GetAllUserData()[i].Address; row["Email"] = Dal.GetAllUserData()[i].Email; row["Phone"] = Dal.GetAllUserData()[i].Phone; dt.Rows.Add(row); } MenuGrid.DataSource = dt; MenuGrid.DataBind(); } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataTable dt = new DataTable(); DataRow row; dt.Columns.Add("PizzaID"); dt.Columns.Add("Name"); dt.Columns.Add("Price"); for (int i = 0; i < manager.GetAllPizza().Count; i++) { row = dt.NewRow(); row["PizzaID"] = manager.GetAllPizza()[i].Id; row["Name"] = manager.GetAllPizza()[i].Name; row["Price"] = manager.GetAllPizza()[i].Price; dt.Rows.Add(row); } MenuGrid.DataSource = dt; MenuGrid.DataBind(); } if (Session["Username"] != null) { LoginPage.InnerText = "Logout"; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Cart"] == null) { CheckoutCart.Visible = false; CartHeaderLabel.Text = "You have nothing in cart!"; } else { CheckoutCart.Visible = true; CartHeaderLabel.Text = "Cart"; if (!Page.IsPostBack) { DataTable dt = new DataTable(); DataRow row; List <Pizza> list = (List <Pizza>)Session["Cart"]; dt.Columns.Add("Name"); dt.Columns.Add("Toppings"); dt.Columns.Add("Price"); for (int i = 0; i < list.Count; i++) { row = dt.NewRow(); row["Name"] = list[i].Name; row["Toppings"] = list[i].Toppings; row["Price"] = list[i].Price; dt.Rows.Add(row); } MenuGrid.DataSource = dt; MenuGrid.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataTable dt = new DataTable(); DataRow row; dt.Columns.Add("PizzaID"); dt.Columns.Add("Name"); dt.Columns.Add("Toppings"); dt.Columns.Add("Price"); for (int i = 0; i < Dal.GetAllPizza().Count; i++) { row = dt.NewRow(); row["PizzaID"] = Dal.GetAllPizza()[i].PizzaID; row["Name"] = Dal.GetAllPizza()[i].Name; row["Toppings"] = Dal.GetAllPizza()[i].Toppings; row["Price"] = Dal.GetAllPizza()[i].Price; dt.Rows.Add(row); } MenuGrid.DataSource = dt; MenuGrid.DataBind(); } }