[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2011-05-09
Medium Priority
Last Modified: 2012-05-11
I have a dropdownlist that lists the states....yet when the user clicks a state...that value doesn't post...
Question by:GlobaLevel
LVL 10

Author Comment

ID: 35725444
its a postback issue it gets written over on postbakc and I cant remember how to solve
LVL 11

Expert Comment

ID: 35725892
Hello, You should change the property IsPostBack = Enable
LVL 16

Accepted Solution

Rose Babu earned 2000 total points
ID: 35726547

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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question