private void BindGrdRevenueDetails() { DataTable dt_GetOppDetails = obj_clsGeneralFunction.GetOpportunityRevenueDetails(Convert.ToInt32(ViewState["OpportunityRevID"])); GVProducts.DataSource = dt_GetOppDetails; GVProducts.DataBind(); }
//Populates Grid View on Page public void populateGV() { BL.Inventory inventory = new BL.Inventory(); if (inventory.GetAllProducts().Count > 0) { var productList = inventory.GetAllProducts(); GVProducts.DataSource = productList; GVProducts.DataBind(); } else { var productList = inventory.GetAllProducts(); GVProducts.DataSource = productList; productList.Add(new Product() { ProductID = 0, CategoryID = 0, Name = "N/A", Type = "N/A", Platform = "N/A", AmountAvailable = 0, Price = 0, Description = "N/A", ImageFile = "N/A" }); GVProducts.DataBind(); productList.RemoveAt(0); GVProducts.Rows[0].Cells.Clear(); GVProducts.Rows[0].Cells.Add(new TableCell()); GVProducts.Rows[0].Cells[0].ColumnSpan = GVProducts.Columns.Count; GVProducts.Rows[0].Cells[0].Text = "No Products Available!"; GVProducts.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } }
protected void Page_Load(object sender, EventArgs e) { productID = (int)Session["CurrentProduct"]; if (productID == -1) { Response.Redirect("errorPage.aspx"); } // Function to create hardcoded data table // Will be easy to replace with SQL data table eventually FillProductTable(); // Datatable is used as datasource for the gridview // Gridview will eventually allow for sorting methods GVProducts.DataSource = productTable; // Applies data to gridview GVProducts.DataBind(); }