Groups | Blog | Home
all groups > asp.net webcontrols > july 2003 >

asp.net webcontrols : DropDownList Getting Value



Belton
7/27/2003 7:08:01 PM
I have created a web form that includes DropDownList boxes that are
populated during method of the page via a databind with database tables.
When the data entry is completed and the add button clicked, I am unable to
capture the selected value of any of the ddl's. I have noticed that when
the ddl items are initially selected they are high lighted. They loose this
high light, however, when the control looses focus. The correct selected
item remains visible in the control, but I cannot for the life of me get the
selected item programmatically.



Jos
7/28/2003 10:27:42 AM
[quoted text, click to view]

My guess is that you are databinding again on postback.
This causes your server to lose the state of your list.

Try changing your Page_Load event in something like this (for VB):

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then
-----Bind your lists here-----
End If

End Sub

--

Jos Branders

--

Jos Branders

Belton
7/28/2003 10:40:32 PM
Tired your suggestion and, with some trial and error on what to put inside
and outside the "if" block, it is working great.

Thanks Jos

[quoted text, click to view]

AddThis Social Bookmark Button