我的数据要一行一行的添加,也就我获取一次数据我就调用我写的DataTable添加行的方法添加一次,
但是这样这样无论我添加几次都只拿到了最后一天记录,有没有什么好的方法可以让我获取所有的
这题我给五十分,最先给出正确 答案的我给30分
但是这样这样无论我添加几次都只拿到了最后一天记录,有没有什么好的方法可以让我获取所有的
这题我给五十分,最先给出正确 答案的我给30分
解决方案 »
- [StringTemplat] 的对象标签,在.net的.aspx页面里面截取字符
- 求助 微软RDLC报表 无法选择数据源类型。
- 如何实现查询时输入拼音就能搜索到数据库中对应的中文字段(数据库中无拼音简码列)
- 在.net里面 FCL是什么意思啊?作用?
- asp.net 反射的问题
- 微软的TREEVIEW如何让他点+,-展开不要用刷新页面,点节点才刷新?
- 运用realplay播放器,我怎么样才能把参数传进来啊!~~(帮忙下)
- [开心]ASP.net下aspx和cs的继承问题终于解决了
- 如何实现在网页上读取WMA文件的信息(唱片集,歌手名等)??
- 只有最后10分了:跳出for循环的语句是什么?
- gridview简单问题,解决马上结贴啊
- javascript 比较时间问题帮忙看下
{
if (!xtraTable.Columns.Contains(name))
{
DataColumn xtraDc = new DataColumn(name);
xtraTable.Columns.Add(xtraDc);
}
}
xtraTable.AcceptChanges();
for (int j=0;j< GridView1 .Rows .Count ; j ++)
{
Pid = mydt.Rows[j][2].ToString();
if (Pid == i) //如果符合
{
str += ",'" + setime + "','" + Msg + "','0')";
if (balcls.sqlcom(str))
{
//Response.Write("<script>alert('xxxx');</script>"); }
}
else
{
continue;
}
}
Session["mytable"]=Tb1;或者用Cache都可以.
这是我现在写的代码:
public DataSet InsertDataTable(string CustomerID,string Rolls,string WeightQty,string LengthQty,string empID,string prodID)
{
DataSet dataset = daset;
DataTable table=dt;
//定义表结构
table.Columns.Add("CustomerID",typeof(System.String));
table.Columns.Add("ProdID",typeof(System.String));
table.Columns.Add("Rolls",typeof(System.String));
table.Columns.Add("WeightQty",typeof(System.String));
table.Columns.Add("LengthQty",typeof(System.String));
table.Columns.Add("Creater",typeof(System.String));
DataRow datarow =table.NewRow();
//添加新行
datarow[0]=CustomerID;
datarow[1]=prodID;
datarow[2]=Rolls;
datarow[3]=WeightQty;
datarow[4]=LengthQty;
datarow[5]=empID;
table.Rows.Add(datarow);
dataset.Tables.Add(table);
return dataset; }
session["tablevalue"]=dt
再加一个Session["mytable"]=Tb1就是正解楼主应给他们两个
private DataTable _cacheTable;public DataTable cacheTable() //返回一个定义好结构的DataTable,如果为空则初始化一个
{
get
{
if(_cacheTable == null)
{
_cacheTable= new DataTable();
_cacheTable.Columns.Add("CustomerID",typeof(System.String));
_cacheTable.Columns.Add("ProdID",typeof(System.String));
_cacheTable.Columns.Add("Rolls",typeof(System.String));
_cacheTable.Columns.Add("WeightQty",typeof(System.String));
_cacheTable.Columns.Add("LengthQty",typeof(System.String));
_cacheTable.Columns.Add("Creater",typeof(System.String));
}
return _cacheTable;
}
}public void InsertDataTable(string CustomerID,string Rolls,string WeightQty,string LengthQty,string empID,string prodID)
//注意这个函数不返回值,也可以返回true false之类标志插入成功与否,Dataset不是必须的
{
DataTable table = _cacheTable;
DataRow datarow =table.NewRow();
//添加新行
datarow[0]=CustomerID;
datarow[1]=prodID;
datarow[2]=Rolls;
datarow[3]=WeightQty;
datarow[4]=LengthQty;
datarow[5]=empID;
table.Rows.Add(datarow);
} 以下函数为你最终要使用这个插入了多行的DataTable的地方
public void f(){
for(int i=0;i<cacheTable.rows.count;i++){
....
}
}
就是我首先添加一行,我添加第二行的时候我只追加不覆盖
谢谢各位给我解决问题!