close
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; private DataTable GetData() { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new System.Data.DataColumn("Column1", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column2", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Column3", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Column4", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Column5", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column6", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column7", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column8", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column9", typeof(int))); dt.Columns.Add(new System.Data.DataColumn("Column10", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Column11", typeof(String))); int totalprice = 0; List orderlist = (List)Session["orderlist_session"]; if (orderlist != null) { int i = 0; foreach (orderProdObj element in orderlist) { dr = dt.NewRow(); dr[0] = i; dr[1] = element.name; dr[2] = element.colorName; dr[3] = element.size; dr[4] = Convert.ToInt16(element.count); dr[5] = Convert.ToInt16(element.totalCount); dr[6] = Convert.ToInt16(element.buyPrice); dr[7] = Convert.ToInt16(element.count) * Convert.ToInt16(element.buyPrice); dr[8] = element.no; dr[9] = element.prodDLink; dr[10] = element.prodImg; dt.Rows.Add(dr); totalprice = totalprice + (Convert.ToInt16(element.count) * Convert.ToInt16(element.buyPrice)); i++; } } totalText.Value = totalprice.ToString(); //Response.Write(totalprice); return dt; }
全站熱搜