c#创建Table

private void BindDatazhangting()
{
DataTable dt = new DataTable();
dt.Columns.Add("channel", Type.GetType("System.String"));
dt.Columns.Add("target", Type.GetType("System.Int32"));
dt.Columns.Add("this_order", Type.GetType("System.Int32"));
dt.Columns.Add("last_order", Type.GetType("System.Int32"));
dt.Columns.Add("ratio", Type.GetType("System.Int32"));
dt.Columns.Add("complete", Type.GetType("System.Int32"));
dt.Rows.Add();
DataRow dr = dt.NewRow();
dr["channel"] = "短信";
dr["target"] = 1233;
dr["this_order"] = 1233;
dr["last_order"] = 1233;
dr["ratio"] = 1233;
dr["complete"] = 1233;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["channel"] = "短信";
dr["target"] = 1233;
dr["this_order"] = 1233;
dr["last_order"] = 1233;
dr["ratio"] = 1233;
dr["complete"] = 1233;
dt.Rows.Add(dr);

dr = dt.NewRow();   //插入数据
dr["channel"] = "短信";
dr["target"] = 1233;
dr["this_order"] = 1233;
dr["last_order"] = 1233;
dr["ratio"] = 1233;
dr["complete"] = 1233;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["channel"] = "短信";
dr["target"] = 1233;
dr["this_order"] = 1233;
dr["last_order"] = 1233;
dr["ratio"] = 1233;
dr["complete"] = 1233;
dt.Rows.Add(dr);


//dlzhangting.DataSource = dt;//绑定datalist
//dlzhangting.DataBind();
}

posted @ 2016-03-04 14:30  饮水思源^0^  阅读(5151)  评论(0编辑  收藏  举报