Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am using c#.net , asp.net and vs2008.

I need to pass DataTable data one webpage to another webpage using property or other method .

How to do this ..

please suggests or any idea

Regards
mukesh
Posted

hi,
pseudo code you can try

pass the value to session

on your 1st page
DataTable dt = new DataTable(); 
dt = (DataTable)Session["ss"]; 



on the next page
C#
DataTable tb= new DataTable();
Session["ss"] = tb; 



hope this may help you
Happy coding:)
 
Share this answer
 
Comments
jaideepsinh 4-Sep-13 3:29am    
+ve 5.
Through viewstate you cannot carry data from one page to another page. ViewState data will be avaialable for pariculat page.

For your case use session it will carry data from one page to another page.
Note : Don't forgot to clear session variables.

Examples :
C# :
C#
Page 1 
DataTable dtTest =new DataTable();
Session["data"]=dtTest;

Page 2
DataTable dt=new DataTable();
dt=(DataTable)Session["data"];

VB :
Page 1
VB
Dim dtTest as DataTable=new DataTable()
Session("data")=dtTest

Page 2
Dim dt as DataTable=new DataTable()
dt=CType(Session("data"), DataTable)
 
Share this answer
 
v2
Comments
Menon Santosh 5-Sep-13 13:43pm    
my +5
Member 11885934 17-Nov-15 4:51am    
thank you so much for this code

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