关于在dataTable中插入别的相同字段的dataTable中的dataRow怎么添加
DataSet ds = new DataSet();
if (Session["typeName"] != null)
{
ds = (DataSet)Session["typeName"];
}
else
{
string sqlStr = "select * from type where type='单机设备'";
ds = db.getDS(sqlStr);
Session["typeName"] = ds;
}
DataListMenu.DataSource = ds;
DataListMenu.DataKeyField = "ID";
DataListMenu.DataBind();
DataSet ds1 = new DataSet();
DataTable dt1=new DataTable();
dt1=ds.Tables[0].Clone();
DataRow[] drs = dt1.Select("type='单机设备'");
DataRow ss;
for (int a = 0; a < drs.Length; a++)
{
drs[a].ItemArray = dt1.Rows[a].ItemArray;
dt1.Rows.Add(drs[a]);
//ss = dt1.NewRow();
//ss = drs[a];
//dt1.Rows.Add(ss);
}
ds1.Tables.Add(dt1);
Response.Write(ds1.Tables[0].Rows.Count);
Response.Write(dt1.Rows.Count);
for (int a = 0; a < ds1.Tables[0].Rows.Count; a++)
{
DropDownList1.Items.Add(ds1.Tables[0].Rows[a]["typeName"].ToString());
}
代码如上
表字段如下
typeName type createTime
灌装机系列 单机设备 2009-11-16 16:48:39.000
双卡封口机系列 单机设备 2009-11-16 16:48:39.000
单卡封口机系列 单机设备 2009-11-16 16:48:39.000
熏蒸炉 冷熏炉 煮锅系 单机设备 2009-11-16 16:48:39.000
滚揉机 制冷滚揉机 滚 单机设备 2009-11-16 16:48:39.000
斩拌机系列 单机设备 2009-11-16 16:48:39.000
搅拌机系列 整套设备 2009-11-16 16:48:39.000
盐水注射机系列 整套设备 2009-11-16 16:48:39.000
切片切块机系列 单机设备 2009-11-16 16:48:39.000
灌装机系列 整套设备 2009-11-16 16:48:39.000
双卡封口机系列 整套设备 2009-11-16 16:48:39.000
单卡封口机系列 整套设备 2009-11-16 16:48:39.000
熏蒸炉 冷熏炉 煮锅系 单机设备 2009-11-16 16:48:39.000
滚揉机 制冷滚揉机 滚 单机设备 2009-11-16 16:48:39.000
斩拌机系列 单机设备 2009-11-16 16:48:39.000
搅拌机系列 单机设备 2009-11-16 16:48:39.000
盐水注射机系列 单机设备 2009-11-16 16:48:39.000
切片切块机系列 单机设备 2009-11-16 16:48:39.000