?
Solved

dropdownlist selectedvalue problem

Posted on 2006-05-18
1
Medium Priority
?
865 Views
Last Modified: 2012-08-13
I'm populating two dropdownlists in my page Load event. The functions use SQL to get values from my tables and the lists are bound. I have a third dropdownlist that I populate in the HTML section of my aspx.

 When I use a button click event to process using the selectedvalues from the dropdownlists, the HTML dropdown (3) works fine but the two SQL dropdowns do not seem to remember the selectedvalues.

One SQL dropdown is a list of dates (2) and the other is a list of ID's that are negative numbers (1).

The rough code is:

Sub Page_Load(sender As Object, e As EventArgs)
MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("RS"))
    GET_Dates 'DropdownList2
    GET_Funds 'DropdownList1

    If Not Page.IsPostBack Then
        MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("RS"))
    End If
End Sub

Sub Button1_Click(sender As Object, e As EventArgs)

    message.text = DropDownList2.SelectedValue & " " & DropDownList1.SelectedValue & " " & DropDownList3.SelectedValue
 
End Sub

Dropdown 2 and 1 display the first item of the list and 3 displays the selected item.

Thanks for the help.

0
Comment
Question by:mfony
1 Comment
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 16708929
Hi mfony,

Because you are repopulating the dropdowns every time. You only need to populate a dropdown on the initial page load not on each postback
Sub Page_Load(sender As Object, e As EventArgs)

    If Not Page.IsPostBack Then
        MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("RS"))
        GET_Dates 'DropdownList2
        GET_Funds 'DropdownList1
    End If
End Sub
Tim Cottee
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
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

750 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