web form & session

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I made a web form with a drop down list. The user can make a choice from the
dropdownlist. The result of this must be placed in a session-variable. This
is my code.

private sub cmdOK_click(...)
Session("ID")=dropdownlist1.selectedvalue
Response redirect("main.aspx").
end sub

But the session-variable is ALWAYS 1. Why ?

Bart
 
Hi Bart,

In you Page_Load, are you using :
if not Page.IsPostBack()...
<code to fill your controls goes here>
end if
to avoid refreshing your dropdownlist1 ?

If not, each time your page loads, it will refresh your dropdown list,
resetting it to the first item in the list (which probably has a value of 1,
in your case)

Hope this helps,

Andrei.
 
Back
Top