DataSet DataTable操作

时间:2022-11-24 08:25:29

    DataSet ds = new DataSet();
            DataTable dt = new DataTable("OrderList");
            dt.Columns.Add(new DataColumn("ID", typeof(string)));
            dt.Columns.Add(new DataColumn("FLMC", typeof(string)));
            dt.Columns.Add(new DataColumn("TJSJ", typeof(string)));
            ds.Tables.Add(dt);
            DataRow dr = ds.Tables[0].NewRow();
            dr[0] =1;
            dr[1] = "建筑安装工程造价指标分析表";
            dr[2] = "";
            ds.Tables[0].Rows.Add(dr);
            dr = ds.Tables[0].NewRow();
            dr[0] =2;
            dr[1] = "建筑安装(装饰装修)工程主要工料指标分析表";
            dr[2] = "";
            ds.Tables[0].Rows.Add(dr);
            dr = ds.Tables[0].NewRow();
            dr[0] =3;
            dr[1] = "人材机分析表";
            dr[2] = "";
            ds.Tables[0].Rows.Add(dr);
            DataGrid1.DataSource = ds.Tables[0].DefaultView;
            DataGrid1.DataBind();