手建DataTable 表格

 DataTable dt = new DataTable();



        DataColumn dc1 = new DataColumn();

        dc1.ColumnName = "列名1";



        DataColumn dc2 = new DataColumn();

        dc2.ColumnName = "列名2";



        dt.Columns.Add(dc1);

        dt.Columns.Add(dc2);



        DataRow dr1 = dt.NewRow();

        dr1["列名2"] = "行值1";

        dr1["列名1"] = "行值2";



        dt.Rows.Add(dr1);

你可能感兴趣的:(Datatable)