Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Managing state between postbacks to server
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Web forms
Title:
Managing state between postbacks to server
Miscellaneous
Thread ID:
00640625
Message ID:
00640625
Views:
54
I have a web form that has to post back to the server to refresh a combo box depending on what the user has selected in another combo box. I need the ability to save a couple of variables when this is done.

According to the book I have (and I know I got this to work using Beta 2) - this is the code I need using 'ViewState' to get this to work:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            strTableName = "blah"         ' for testing purposes
            strDatabaseName = "Blah,Blah" ' for testing purposes
            Call FillDBCombo()
            Call FillTableCombo()
        Else
            strTableName = ViewState("strTableName")
            strDatabaseName = ViewState("strDatabaseName")
        End If
    End Sub

    Sub Page_PreRender(ByVal Sender As Object, ByVal E As EventArgs)
        ViewState("strTableName") = strTableName
        ViewState("strDatabaseName") = strDatabaseName
    End Sub
However, when it does a postback, it resets the variables to empty strings. Any idea whay I'm missing here - or is there a better way to do this ?

Thanks in advance,

Al
Al Williams

Anola MB, CANADA
Next
Reply
Map
View

Click here to load this message in the networking platform