473,583 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing DataTable Across ASPX Pages

Hello,

I am trying to come up with the best way to pass large amounts of data from
page to page, namely a data table.

The user needs to enter data into a form in one page and confirm it on
another. Session variables seem like the easiest, but I'm afraid of
crashing the server after deploying with a few hundred users as opposed to
just a few developers/testers. Any ideas?

Thanks,

Eric
Nov 18 '05 #1
1 6884
Eric,

You may use Server.Transfer to make the previous page's context available.

Here's some sample code from the code library on my site:

Use Server.Transfer to pass values from one page to another
If you don't want to use session variables or have data appear in the query
string of your page then utilizing the Server.Transfer method for moving
from one page to another is a great way to make one page's properties
available to another.

Sample Code:

'---On your first page create a public property that accesses the value you
want to make accessible to other pages.

Public ReadOnly Property UserId() As Int32
Get
'---Where _UserId is a private variable on the page
Return _UserId
End Get
End Property

'---Use Server.Transfer to execute the page transferred to.

Private Sub SubmitButton_Cl ick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles SubmitButton.Cl ick
Server.Transfer ("page2.aspx ")
End Sub

'---Recreate the page1 object on page2 and get the user id.

Private _UserId As Int32

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

If Not IsPostBack Then
Dim Page1 As Page1 = CType(Context.H andler, Page1)
_UserId = Page1.UserId
End If

End Sub

If you're going to have multiple pages that you could be arriving at another
page from you will also need to be able to tell which page the user has
arrived from before you may correctly cast the context object.

The way to do that is:

Server.Transfer - Get the name of the page transferred from
When Server.Transfer is used it allows access to the previous page's
variables, but you have to re-create the previous page by performing CType()
on the context object.

This is fine if users can only move to a new page from one single place, but
if a user can arrive at the same page from multiple pages how do you know
which page the context is arriving from? If you don't you can't recreate the
previous page to access its variables.

This code get's the name of the previous page.

Then you can perform a Select Case based on page name to re-create the
previous page from the context object.

Sample Code:

Public Class GetTransferredC ontextPageName
Public Function GetPageName(ByV al ContextTransfer red As
System.Web.Http Context) As String
Try
Dim Page As Object = ContextTransfer red.Handler
Dim PageName As String = LCase(Page.GetT ype.ToString)
PageName = Replace(PageNam e, "_aspx", "")
PageName = Replace(PageNam e, "asp.", "")
Return PageName
Catch e As Exception
Throw e
End Try
End Function
End Class
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Eric" <No*@y.José> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hello,

I am trying to come up with the best way to pass large amounts of data from page to page, namely a data table.

The user needs to enter data into a form in one page and confirm it on
another. Session variables seem like the easiest, but I'm afraid of
crashing the server after deploying with a few hundred users as opposed to
just a few developers/testers. Any ideas?

Thanks,

Eric

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3029
by: Matt M | last post by:
Ok. So I'm passing values between web pages, as per microsoft's framework development guide (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht ml/cpconPassingServerControlValuesBetweenPages.asp) So, I have two pages, one that has some public properties and fires a Server.Transfer("receivepage.aspx"); The...
1
2192
by: eSapient | last post by:
My objective was to implement a 'Wait' page by using a combination of an asynchronous call and a Session variable to signal the end of the wait. My first page has: --------------------------------------------------------------- private void cmdSubmit_Click(object sender, System.EventArgs e) { Thread LongProcessThread = new Thread(new...
3
1470
by: Jon Paugh | last post by:
Hi, If I have several aspx pages that I want to share across multiple web applications, how would I organize them? Basically, a subset of the pages on a given site will be on several sites. These pages will interact with a database, check security, etc. I have seen this KB article: http://support.microsoft.com/default.aspx?kbid=324785
4
2344
by: Gibs | last post by:
Hi I have two aspx pages in a frame and in the top page i am creating the controls dynamically and putting in a place holder. I have a hyperlink in this page to populate the data in the bottom aspx page. When the user clicks this hyperlink i need to populate the bottom aspx pagebased on the user imputs. So i need to pass the values from...
6
1900
by: Victor Hadianto | last post by:
Hi All, I'm a beginner with ASP.Net so please bear with me. I'm having difficulties trying to understand the behaviour of static variable across multiple ASP.Net page. My static variable is a Hashtable and located in a dll which is referenced by my ASP.Net aspx pages. In one pages I have a form and in the form submit I remove some items...
10
2208
by: Suresh | last post by:
how to share Session Sharing Across the domain
2
4073
by: Chad | last post by:
Sorry to create a new thread on an old post but I didn't get a viable answer and thought that the odds were against me getting one unless I started a new thread. My question was this: I want to pass a string variable from default3.aspx to default2.aspx. I create a property in default2.aspx, called "X", and assign a value. I then call...
2
2666
by: =?Utf-8?B?Um9oaXQ=?= | last post by:
I need to pass a DataTable object by value over a tcp socket. Unfortunately, I am forced to use the .NET framework ver. 1.1 for reasons that I don't want to get into. Does anybody know how I can do this? Note: if I had been luck enough to be able to use the .NET Framework ver. 2.0, I could have just converted the table to XML and sent it...
3
2277
by: dbuchanan | last post by:
newbie question What are the various ways that data can be passed between pages. For example; How is data about the logged in user passed to subsequent pages Thank you, Doug
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8314
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8185
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.