DropDownList reset itself

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I have a DropDownList.
When I click on an item in the dropped down box I see that item for an
instance in the text box and then the text changes so that item 2 is always
selected.

I don't believe it is not my code-behind because I've commented most of it
out and have a break point in the load event that initializes the box.

I have autopostback set to true and know it does post back.

That is probably where the change takes place but I don't know how to stop
the change or even why it is changing.

I'm guessing that the view state refers to the state of the box before the
click occured.

Got any suggestions?


Thanks
 
Mark said:
Sounds like you're populating the DropDownList in the Page_Load
event. If so, try moving the code which does the populating into the
Page_Init event.

Either that or check if the page is a postback:

sub page_load(...) handles ....
if not(page.ispostback) then
' initialize dropdown(s)
end if
end sub

Andrew
 
Andrew Morton said:
Either that or check if the page is a postback:

sub page_load(...) handles ....
if not(page.ispostback) then
' initialize dropdown(s)
end if
end sub

Andrew

I am populating in the Load event but I do check ispostback.
After much searching I found the answer. I'm like to pass it on:
It seems that if you're using ListItems
there should not be duplicates in the Values.
Say we have items containing values "3" and the "5"
with "3" first.
Then if "5" is clicked "3" will become selected

Thanks
 
Back
Top