private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { gridMaster.DataSource = db.GetCategoriesProductsDataSet(); gridMaster.DataMember = "Categories"; gridMaster.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { Session["SelectedCategory"] = null; } // Refresh the DataSet every time, even for postbacks. // This is not a performance drag, because the DataSet // is usuaslly cached. gridMaster.DataSource = db.GetCategoriesProductsDataSet(); gridMaster.DataMember = "Categories"; gridMaster.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // Update the product list. ds = db.GetCategoriesProductsDataSet(); gridProducts.DataSource = ds.Tables["Products"]; gridProducts.DataBind(); // Check for the shopping cart. If it doesn't // exist, create a new cart and make it available. //if (Profile.Cart == null) //{ // Profile.Cart = new ShoppingCart(); //} }
private void Page_Load(object sender, System.EventArgs e) { if (Session["SelectedCategory"] != null) { DataSet ds = db.GetCategoriesProductsDataSet(); DataView view = ds.Tables["Products"].DefaultView; view.RowFilter = "CategoryID =" + Session["SelectedCategory"].ToString(); // The easiest way to calculate the total value for // the displayed records is to work through the DataView, // not the DataTable. That's because the DataView will // include only the rows in the apporopriate category. foreach (DataRowView rowView in view) { DataRow row = rowView.Row; valueInStock += (short)row["UnitsInStock"] * (decimal)row["UnitPrice"]; } // Bind the grid. gridDetails.DataSource = view; gridDetails.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { // Update the product list. ds = db.GetCategoriesProductsDataSet(); gridProducts.DataSource = ds.Tables["Products"]; gridProducts.DataBind(); // Check for the shopping cart. If it doesn't // exist, create a new cart and make it available. if (Session["Cart"] == null) { cart = new ShoppingCart(); } else { cart = (ShoppingCart)Session["Cart"]; } }