Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

can we transfer data from one page to another page using
viewstate if so how?if not y?

Answer Posted / william niver

Yes, you can get the PreviousPage ViewSate.

I have created two pages (Default.aspx and LandingPage.aspx)

Default.aspx has a LinkButton with a PostBackUrl pointing
to LandingPage.aspx.

Code Behind for Default.aspx:

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
ViewState("MyValue") = "I am a test value"
End Sub

Public Function GetViewState() As System.Web.UI.StateBag
Return ViewState
End Function

End Class

Code Behind for LandingPage.aspx:

Partial Class LandingPage
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
If PreviousPageViewState IsNot Nothing Then
If PreviousPageViewState("MyValue") IsNot
Nothing Then
'Value is retrieved from the PreviousPage
ViewState
MyBase.Controls.Add(New LiteralControl
(PreviousPageViewState("MyValue")))
End If
End If
End Sub

Private ReadOnly Property PreviousPageViewState() As
StateBag
Get
Dim ReturnValue As System.Web.UI.StateBag =
Nothing
If PreviousPage IsNot Nothing Then
Dim MyTypeObj As Object = DirectCast
(PreviousPage, Object)
For Each MethodObj As Reflection.MethodInfo
In PreviousPage.GetType.GetMethods()
If MethodObj.Name = "GetViewState" Then
ReturnValue = MethodObj.Invoke
(MyTypeObj, Nothing)
Exit For
End If
Next
End If
Return ReturnValue
End Get
End Property

End Class

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is & in a url?

966


Define session in asp.net.

990


What are type/key pairs in client script registration? Can there be 2 scripts with the same type/key pair name?

952


Will the asp.net validators run in server side or client side?

1152


What is a master page and what does it do?

932


Explain what is an assembly?

977


Hello, Using Visual Studio 2005 (VB) I am working to create a Web Site implementing the following: Within a gridView I have placed a dropdownlist control with a DataSourceID="SDSLkupList". SDSLkupList is a sqlDataSource used to store a lookup list for dropdownlist translation from ID to text. SDSLkupList contains the translation text and other fields related to the dropdown selection ID. (Thought it would be efficient to get everything at the same time.) I would like to provide the user the ability to select from the dropdownlist and, based on the selection, use labels to list related columns stored on the SDSLkupList in separate gridView columns. I have read that SqlDataSources are not meant to be used for individual controls. Since SDSLkupList contains all related information, is there a way to do a find using the dropdownlist selectedValue? (I was not able to discover one.) Otherwise, what should I use? It would need to set the labels on the gridView DataRowBound event as well as the SelectedIndexChanged events. Has anyone done this? Any help would be appreciated. Thanks in Advance. Neal

1824


What are the properties of the eventargs argument when capturing keyboard events?

1085


What is the difference between table and query?

978


What are the file extensions for razor views?

1150


Can I tap into other windows livetm services?

990


In order to bind the data from a data source to the Repeater control what property is set and what method must you call in your code,?

1076


What is asp net objects?

1062


What are the main advantages of using asp.net?

1042


Define the types of configuration files.

983