datatable 赋值

DataTable DT = new DataTable("MyDT"); //实例一个空datatable DT.Columns.Add("Name", typeof(string)); //为datatable添加一些列 DT.Columns.Add("Value", typeof(string)); //为datatable添加一些列 DataRow DR; //实例一个DT的新行 DR = DT.NewRow(); DR["Name"] = "myName"; //为新行的字段赋值 DR["Value"] = "myNameValue"; DT.Rows.Add(DR); //将新行添加到datatable中 DR = DT.NewRow(); DR["Name"] = "myName1"; //为新行的字段赋值 DR["Value"] = "myNameValue1"; DT.Rows.Add(DR); //将新行添加到datatable中 //删除行 //Index = n;//n为要删除的行数 //this.DT.Rows.RemoveAt(Index);
posted @ 2015-07-22 11:06  范海辛1990  阅读(935)  评论(0编辑  收藏  举报