Example #1
0
 //Populates grid view for 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 Data!";
         GVProducts.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
     }
 }