|
-
Nov 7th, 2002, 04:16 AM
#1
Thread Starter
Lively Member
Viewstate ...
Hello everybody,
I'm already since a few day looking for my solution ...
I want to save a viewstate with a certain value. When the first autopostback occurs, then my viewstate isn't saved, the second postback then I have my viewstate but it's like one step behind.
Look at my following example. It's very simple.. it contains one dropdownlist which is on autopostback=true
VB Code:
Public Class WebForm2
Inherits System.Web.UI.Page
Protected WithEvents list1 As System.Web.UI.WebControls.DropDownList
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 Page.IsPostBack Then
list1.Items.Add("test")
list1.Items.Add("test2")
End If
Response.Write(viewstate("test"))
End Sub
Private Sub list1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles list1.SelectedIndexChanged
viewstate("test") = list1.SelectedItem.Text
End Sub
End Class
When you select a value in the list, then the autopostback occurs. It doesn't give me a value. But when you choose a second value now, then the first value will be written on the page...
Please don't look at the selecteditem value that I pass through. I know this goes directly. It's just for TESTING purposes.
My final thought is that I have three or four dropdownlists and that I can know with the viewstate which combo has been used.
Example : combo1_selectedindexchanged gives viewstate("combo")="combo1"
combo2_selectedindexchanged gives viewstate("combo")="combo2"
Does anyone know a solution for my problem ?
Thanks in advance !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|