Click here to Skip to main content
15,881,568 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
Hi
I have created a web application in C# .net4.0.In that application, i want to pass data present in a DATASET from one form to another and i want to place that data in the textboxes present in the 2nd form. How can i do that? Plz help me

Thanking you
Posted

Hi ,
You can use Session
C#
//for assign
       DataSet ds = new DataSet();
       Session.Add("Name", ds);
       // for retrieve
       ds = (DataSet)Session["Name"];

Exploring Session in ASP.NET[^]
Session management options in ASP.NET[^]
Session Management in ASP.NET[^]
ASP.NET Session Management Internals[^]
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]
Best Regards
M.Mitwalli
 
Share this answer
 
Comments
VJ Reddy 22-May-12 23:09pm    
5!
Mohamed Mitwalli 23-May-12 3:25am    
Thanks VJ :)
Prasad_Kulkarni 23-May-12 3:29am    
Good references! 5!
Mohamed Mitwalli 23-May-12 3:32am    
Thanks Prasad :)
Mohammad A Rahman 23-May-12 6:26am    
my 5!
 
Share this answer
 
Comments
Prasad_Kulkarni 23-May-12 0:33am    
Good links +5!
P.Salini 23-May-12 4:48am    
Thank you Prasad.
Mohammad A Rahman 23-May-12 6:27am    
my 5!
P.Salini 23-May-12 7:01am    
Thank you Rahman
Client Side:
View State – Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.
Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.
Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.
Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.
Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

Server Side:
Application State - Application State information is available to all pages, regardless of which user requests a page.
Session State – Session State information is available to all pages opened by a user during a single visit.
Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.

See the references in all above answers they are having more details with examples.
 
Share this answer
 
Comments
Mohamed Mitwalli 23-May-12 3:34am    
5+ for your explanation :)
Prasad_Kulkarni 23-May-12 3:37am    
Thank you
P.Salini 23-May-12 4:48am    
My 5!
Prasad_Kulkarni 27-Jun-12 5:12am    
Thank yo P.Salini!
Hi,

save dataset in application state like following
C#
sqlDataAdapter1.Fill(dSet);
System.IO.StringWriter sw = new System.IO.StringWriter();

// Write the DataSet to the Application state.
dSet.WriteXml(sw);
Application["dSet"] = sw.ToString();


then u can use it in any page

best luck
happy coding:)
 
Share this answer
 
By using State management concept you will pass data from one page to another

see this links you may get some idea
http://www.dotnetfunda.com/articles/article61.aspx[^]

http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx[^]
 
Share this answer
 
Hi,
you can use Session for pass the value from one page to another page.

Session

From Page:
C#
DataSet ds = new DataSet();
Session["var"] = ds.Tables[0];


To Page:
C#
DataSet ds = new DataSet();
ds = (DataSet)Session["var"];






Regards,
Jitendra
 
Share this answer
 
v4
Comments
jitu8187 23-May-12 13:45pm    
Dear Mitwalli,

If you will see right side, i have already cast session variable in DataSet. so we have to take a DataSet in left side.

Regards,
Jitendra

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