473,473 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Transfering web control data from one page to another

Ben
I used the following code to transfer some web control data from Page1.aspx
to Page2.aspx.
It is successful to get the TextBox.Text over, but the DropDownList data
failed to appear in Page2. I wonder what went wrong?

Page1.aspx.cs
-----------------
public object Dept
{
get
{
return ddlDept.DataSource;
}
}

public string Rcp
{
get
{
return tbRcp.Text;
}
}

Page2.aspx.cs
-----------------
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack )
{
Page1 srcPage = (Page1) Context.Handler;
ddlDept.DataSource = srcPage.Dept;
ddlDept.DataBind();
tbRcp.Text = srcPage.Rcp;
}
}

Thanks in advance,
Ben
Nov 18 '05 #1
2 2408
I'm not 100% sure if this is the reason why you're having problems, but
the DataSource is not persisted in view state, like the Text property
is. That is, it does not survive postbacks. I would imagine this would
work if you set the DataSource and then immediately did a
Server.Transfer(), but I'm wagering you're doing a Server.Transfer()
after postback, no?

Just a shot in the dark... hth!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #2
Ben
Yes, you're right !

Following your pointer, I changed the code to set the DataSource and then
immediately Server.Transfer("Page2.aspx") and then it works.

So to obtain the DataSource from the source page, the only way is to
Server.Transfer after setting the DataSource?

Many Thanks,
Ben

"Scott Mitchell [MVP]" wrote:
I'm not 100% sure if this is the reason why you're having problems, but
the DataSource is not persisted in view state, like the Text property
is. That is, it does not survive postbacks. I would imagine this would
work if you set the DataSource and then immediately did a
Server.Transfer(), but I'm wagering you're doing a Server.Transfer()
after postback, no?

Just a shot in the dark... hth!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!

Nov 18 '05 #3

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

Similar topics

2
by: Niyazi | last post by:
Hi, I have BIG question and I gues it is the BEST question. I have a problem that I am guessing the best solution is to create some sort ..NET Services. This Service(s) must check every...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
by: Piotr Karwatka | last post by:
Hi! I have a little problem an qeustion. In .NET Windows Forms I can do something like that: - i have forms - Form1 Form2, on first form i have TextBox1 control on 2nd form I have Button1...
1
by: Shahid Juma | last post by:
Hi, This may be a very trivial answer but I was wondering if it possible to have a ASP.NET page and on a user click, it transfers to another page. Rather than redirecting to the new page, I want...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
1
by: suneet.taparia | last post by:
Hi, Can anyone help me in finding a method or some url by which I can transfer the data from one page to another page using javascript method without refershing the page. If anyone can help...
10
by: Walshi | last post by:
Hi all, I'm a relative newby to access and VBA etc. My forms and tables etc are working great and saving lots of time...However... I have two databases with the exact same table format. I want...
2
by: Rob Meade | last post by:
Hi all, I have an application which enables a user to register and select a series of resources to go with their profile. At the moment I have an issue on the section where they will select...
13
by: hexagram | last post by:
hi guys can anybody can teach me how to do this scenario Transfering Data of a form to a new form The Scenario is: I have a Delivery Receipt Form (Hardware) with a fields of the following ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.