开发者

How to transfer data to another page

Hai, I have an ASP.NET page with 150 controls and i want to transfer data of these controls to another ASP.NET page. what method would b开发者_如何学运维e best for this task? Number of controls may increase.

Thanks in advance


There are many ways:

  1. Using a Query String (Might not work in your case, only good for transferring small amount of data)
  2. Getting Post Information from the Source Page
  3. Using Session State
  4. Getting Public Property Values from the Source Page
  5. Getting Control Information from the Source Page in the Same Application

Its always preferable to wrap the data you want to transfer in an object and pass it using pt. 3 or Pt. 4 , though in case you have arbitrary number of controls, Pt. 5 may work better for you.

This should cover it comprehensively:

  • MSDN: How to: Pass Values Between ASP.NET Web Pages

  • ASP.NET 2.0 : Accessing controls in Previous Page


You can use datatable , populate the contents in the row and send it using session

Another way is use generic class and transfer it using session.

You can also transfer it using below mentioned code

TextBox previouspagetextbox = (TextBox)PreviousPage.FindControl("currentpagetextbox");

the above mentioned code will be written in the another page where you will access the controls of previous page.

Multiviews is an another option. So you donot need to transfer the contents. It will facilitate you in same page.


As i could understand your need it will be possible through server side session or any other servers side storing mechanism like you can store the data in the database also and then fetch the control values on the next page by the Primary key or any other composite unique combination but at the cost of your page performance i will suggest you better to use ASP:Wizard control that is available from asp.net 2.0. Most of the things will be taken care by the asp:wizard and it will be easy for the user of the page to fill up the information in the controls.

for details ion wizard control read on the following link

Hope it will be helpful. Happy coding.


You can use Server.Transfer('NewPage.aspx', True) to redirect to a new page and that page will have access to all of the controls that were on the previous page. MSDN Article about it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜