会话数据表 [英] Data Table from session
本文介绍了会话数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法将会话与数据集绑定,因此我认为数据表是唯一的解决方案。
如何从我在viewmoddel中创建的Session生成dataTable?
i couldn't bind session with data set ,so that i think that data table is the only solution.
How can i generate dataTable from Session that i have created in the viewmoddel?
推荐答案
如果我没有错,这是你尝试的解决方案
if i am not wrong is this a solution that you were trying
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Rows.Add("Affan");
dt.Rows.Add("osama");
dt.Rows.Add("faraz");
dt.Rows.Add("saqib");
ds.Tables.Add(dt);
//you can contain anything in session but its a bad practice to store huge amount of data in session like dataset or datatable
Session["AddDataTable"] = ds;
//Binding gridview
GridView1.DataSource = ((DataSet)Session["AddDataTable"]).Tables[0];
GridView1.DataBind();
这篇关于会话数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文