asp.net viewstate可以存放datatable对象
2011-08-10 14:28
369 查看
private DataTable CreateDataTable() //生成一个DataTable并赋给ViewState
{
DataTable table = new DataTable();
DataColumn colum;
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.Int32");
colum.ColumnName = "ProductType";
table.Columns.Add(colum);
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.Int32");
colum.ColumnName = "ProductSpecID";
table.Columns.Add(colum);
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.String");
colum.ColumnName = "ProductCode";
table.Columns.Add(colum);
ViewState["detailtable"] = table; //存放table
return table;
}
使用时就直接:
DataTable table = ViewState["detailtable"] as DataTable;
{
DataTable table = new DataTable();
DataColumn colum;
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.Int32");
colum.ColumnName = "ProductType";
table.Columns.Add(colum);
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.Int32");
colum.ColumnName = "ProductSpecID";
table.Columns.Add(colum);
colum = new DataColumn();
colum.DataType = System.Type.GetType("System.String");
colum.ColumnName = "ProductCode";
table.Columns.Add(colum);
ViewState["detailtable"] = table; //存放table
return table;
}
使用时就直接:
DataTable table = ViewState["detailtable"] as DataTable;
相关文章推荐
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- 对 ASP.NET 中 ViewState 对象的荒谬认识
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别..
- ASP.NET状态管理 APPlication,Session,Cookie和ViewState等对象用法和区别
- ASP.Net中用ViewState存储自定义复杂对象后类型转换的一个问题
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别 (转)
- ASP.NET状态管理 APPlication,Session,Cookie和ViewState等对象用法和区别
- ASP.NET入门教程:Web表单维持对象的ViewState
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别 (转)
- ASP.NET在禁用视图状态的情况下仍然使用ViewState对象【转】
- 对象序列化(七):应用实例->asp.net ViewState
- 对 ASP.NET 中 ViewState 对象的荒谬认识(转)
- ASP.NET——Application, Session, Cookie, Viewstate, Cache对象用法和区别
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- ASP.NET中ViewState对象的使用
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别
- ASP.NET Application,Session,Cookie和ViewState等对象用法和区别