protected void FillProductTable() { //int cartCount = (int)Session["CartCount"]; productTable = new DataTable(); productTable.Columns.Add("ProductID", typeof(int)); productTable.Columns.Add("Name", typeof(string)); productTable.Columns.Add("Type", typeof(string)); productTable.Columns.Add("Platform", typeof(string)); productTable.Columns.Add("Price", typeof(decimal)); productTable.Columns.Add("Description", typeof(string)); //productTable.Columns.Add("Image", typeof(string)); List <Models.ProductCart> ProductCartList = (List <Models.ProductCart>)Session["ProductCart"]; BL.ProductsBL productsBLVariable = new BL.ProductsBL(); var ProductRetrieved = productsBLVariable.getSingleProduct(productID); productTable.Rows.Add(productID, ProductRetrieved.Name, ProductRetrieved.Type, ProductRetrieved.Platform, ProductRetrieved.Price, ProductRetrieved.Description /*, ProductRetrieved.ImageFile*/); }
// References for own use // https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable?view=netframework-4.7.2 // https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.gridview.databind?view=netframework-4.7.2 // https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.templatefield?view=netframework-4.7.2 // https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.linkbutton?view=netframework-4.7.2 // Function to create data table for cart protected void FillCartTable() { //int cartCount = (int)Session["CartCount"]; cartTable = new DataTable(); cartTable.Columns.Add("ProductID", typeof(int)); cartTable.Columns.Add("Quantity", typeof(int)); cartTable.Columns.Add("Name", typeof(string)); cartTable.Columns.Add("Type", typeof(string)); cartTable.Columns.Add("Platform", typeof(string)); cartTable.Columns.Add("Price", typeof(decimal)); List <Models.ProductCart> ProductCartList = (List <Models.ProductCart>)Session["ProductCart"]; for (int i = 0; i < ProductCartList.Count; i++) { //System.Diagnostics.Debug.WriteLine("Creating row: " + (i+1) + " for ID:" + ProductCartList[i].ID); BL.ProductsBL productsBLVariable = new BL.ProductsBL(); var ProductRetrieved = productsBLVariable.getSingleProduct(ProductCartList[i].ID); cartTable.Rows.Add(ProductCartList[i].ID, ProductCartList[i].Quantity, ProductRetrieved.Name, ProductRetrieved.Type, ProductRetrieved.Platform, ProductRetrieved.Price); } }