Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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?
Posted
Updated 19-Apr-15 10:38am
v2

1 solution

if i am not wrong is this a solution that you were trying

C#
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();
 
Share this answer
 
v2
Comments
EMNA AYADI 17-Apr-15 18:02pm    
Thank you for your answer, the problem is that i'm storing data in session that comes from a wizard step !
i want to print in PDF those data in the forth step that allow us to see all information entred in the 3 steps !
Rana Waqas 17-Apr-15 20:07pm    
i bind it with gridview so, instead of binding it with gridview you can take print out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900