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:
  1. Public Class WebForm2
  2.     Inherits System.Web.UI.Page
  3.     Protected WithEvents list1 As System.Web.UI.WebControls.DropDownList
  4.  
  5.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.         'Put user code to initialize the page here
  7.  
  8.         If Not Page.IsPostBack Then
  9.             list1.Items.Add("test")
  10.             list1.Items.Add("test2")
  11.         End If
  12.  
  13.         Response.Write(viewstate("test"))
  14.  
  15.     End Sub
  16.  
  17.     Private Sub list1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles list1.SelectedIndexChanged
  18.  
  19.         viewstate("test") = list1.SelectedItem.Text
  20.  
  21.     End Sub
  22. 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 !