怎么将DataTable手动添加的数据在前台页面拿出来,具体一点,代码在下面,前台页面怎么的GridView怎么写
publicDataTableMakeTable(){DataTabledt=newDataTable();DataColumndc1=newDataColumn("NO...
public DataTable MakeTable()
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("NO", System.Type.GetType("System.String"));
DataColumn dc2 = new DataColumn("ItemNumber", System.Type.GetType("System.String"));
DataColumn dc3 = new DataColumn("BatchNo", System.Type.GetType("System.String"));
DataColumn dc4 = new DataColumn("BadCauseName", System.Type.GetType("System.String"));
DataColumn dc5 = new DataColumn("Qty", System.Type.GetType("System.String"));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
//添加数据
DataRow row = dt.NewRow();
row["NO"] = "1";
row["ItemNumber"] = "20180424001";
row["BatchNo"] = "2";
row["BadCauseName"] = "破损";
row["Qty"] = "12";
dt.Rows.Add(row);
row = dt.NewRow();
row["NO"] = "2";
row["ItemNumber"] = "20180424002";
row["BatchNo"] = "3";
row["BadCauseName"] = "裂片";
row["Qty"] = "22";
dt.Rows.Add(row);
row = dt.NewRow();
row["NO"] = "3";
row["ItemNumber"] = "20180424003";
row["BatchNo"] = "4";
row["BadCauseName"] = "裂痕";
row["Qty"] = "32";
dt.Rows.Add(row);
return dt;
} 展开
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("NO", System.Type.GetType("System.String"));
DataColumn dc2 = new DataColumn("ItemNumber", System.Type.GetType("System.String"));
DataColumn dc3 = new DataColumn("BatchNo", System.Type.GetType("System.String"));
DataColumn dc4 = new DataColumn("BadCauseName", System.Type.GetType("System.String"));
DataColumn dc5 = new DataColumn("Qty", System.Type.GetType("System.String"));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
//添加数据
DataRow row = dt.NewRow();
row["NO"] = "1";
row["ItemNumber"] = "20180424001";
row["BatchNo"] = "2";
row["BadCauseName"] = "破损";
row["Qty"] = "12";
dt.Rows.Add(row);
row = dt.NewRow();
row["NO"] = "2";
row["ItemNumber"] = "20180424002";
row["BatchNo"] = "3";
row["BadCauseName"] = "裂片";
row["Qty"] = "22";
dt.Rows.Add(row);
row = dt.NewRow();
row["NO"] = "3";
row["ItemNumber"] = "20180424003";
row["BatchNo"] = "4";
row["BadCauseName"] = "裂痕";
row["Qty"] = "32";
dt.Rows.Add(row);
return dt;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询