- dropdown doesnt return the value the user clicks on...

I have a dropdownlist that lists the states....yet when the user clicks a state...that value doesn't post...
LVL 10
Who is Participating?
Rose BabuSenior Team ManagerCommented:

in your design and code page try the following snippet

Set AutoPostBack=true for that dropdownlist

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">

Open in new window

getting selected data from dropdownlist

Sub Page_Load
    If Not IsPostBack
        Dim state as string =  "Selected Text: " _
        & ddlState.SelectedItem.Text & " Selected Value: " _
        & ddlState.SelectedItem.Value & " Selected Index: " _
        & ddlState.SelectedIndex   
    End If
End Sub

Open in new window

public void Page_Load()
	if (!IsPostBack) {
		string state = "Selected Text: " + ddlState.SelectedItem.Text;
		state += " Selected Value: " + ddlState.SelectedItem.Value; 
		state += "<BR>Selected Index: " + ddlState.SelectedIndex;

Open in new window

Happy Programming.
GlobaLevelProgrammerAuthor Commented:
its a postback issue it gets written over on postbakc and I cant remember how to solve
SAMIR BHOGAYTAFreelancer and IT ConsultantCommented:
Hello, You should change the property IsPostBack = Enable
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.