Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue wih going back and forth between pages

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a page that fills in a text box and also a grid with data. the first issue was each time the page refreshed, all of the text boxes and the GridView were then blank. I solved that by using Session vars to hold the key data elements then repopulaing them when it reloaded each time. I knwo ther eis abetter way. But now If I go to another page and fome back the code above is not even runign since there is no page reload but yet the data in eveything is blank.
So what the best way to do this? I saw something about View state but then it said that was not to hold values?

also what is "good" book to learn .NET 4?

Code:
       'came back from ChoosePerson form
        If Session("PersonType") = "Employee" Then
            'fill the grid
            Me.txtEnterpriseID.Text = Session("EmployeeEnterpriseID")
            Call FindEmployee()
            If Session("GotNominatorName") <> "" Then
                Me.txtNominator.Text = Session("GotNominatorName")
            End If

            Session("PersonType") = ""
            'Session("EmployeeEnterpriseID") = ""
        End If

        If Session("PersonType") = "Nominator" Then
            Me.txtNominator.Text = Session("NominatorFullName")
            'Session("NominatorFullName") = ""
            Session("PersonType") = ""
            'relaod the grid if
            If Session("EmployeeEnterpriseID") <> "" Then
                Call FindEmployee()
            End If
       End If
[code]

DougP
 
ViewState is only available on the page you are posting to. So when you postback to the same page viewstate is available. If you leave the page then come back, the viewstate you orignally saved will not be there. This is where session comes in. It is available throughout the whole session, no matter what page you are in. you can even access it from class files etc.

So, in you case you need to fill in the values you want to based on if the session variable exists, not if it is a postback or not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top