标签:datatable data 自动 nts 增加 tar datetime als div
//创建DataTable DataTable dt = new DataTable("NewDt"); //创建自增长的ID列 DataColumn dc = dt.Columns.Add("ID", Type.GetType("System.Int32")); dc.AutoIncrement = true; //自动增加 dc.AutoIncrementSeed = 1; //起始为1 dc.AutoIncrementStep = 1; //步长为1 dc.AllowDBNull = false; //非空 //创建其它列表 dt.Columns.Add(new DataColumn("Name", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("Age", Type.GetType("System.Int32"))); dt.Columns.Add(new DataColumn("Score", Type.GetType("System.Decimal"))); dt.Columns.Add(new DataColumn("CreateTime", Type.GetType("System.DateTime"))); //创建数据 DataRow dr = dt.NewRow(); dr["Name"] = "张三"; dr["Age"] = 28; dr["Score"] = 85.5; dr["CreateTime"] = DateTime.Now; dt.Rows.Add(dr); dr = dt.NewRow(); dr["Name"] = "李四"; dr["Age"] = 24; dr["Score"] = 72; dr["CreateTime"] = DateTime.Now; dt.Rows.Add(dr); dr = dt.NewRow(); dr["Name"] = "王五"; dr["Age"] = 36; dr["Score"] = 63.5; dr["CreateTime"] = DateTime.Now; dt.Rows.Add(dr);
标签:datatable data 自动 nts 增加 tar datetime als div
原文地址:https://www.cnblogs.com/macT/p/10726887.html