Computing.Net > Forums > Programming > Dropdownlist moves back to Index=0

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dropdownlist moves back to Index=0

Reply to Message Icon

Name: mking (by mkingrey)
Date: September 22, 2005 at 09:39:01 Pacific
OS: xp
CPU/Ram: xp
Comment:

I have three DropDownList Boxes on this Webform and when I click a button (reload the page) the first two boxes stay with the selected value but the third DDL box returns to the original index value of 0 as if the page has been loaded for the first time. All three sit within the "If.IsPostBack = False..." statement under the Page_Load Event. Does anyone know why the third DDL behaves this way?

If Page.IsPostBack = False Then
panel1.Visible = False

Dim myDataSet1 As DataSet = New DataSet
Dim myDataSet2 As DataSet = New DataSet
Dim myDataSet3 As DataSet = New DataSet

Dim SelectCommand1 As String = "Select * FROM Divisions"
Dim SelectCommand2 As String = "Select * FROM Customers"
Dim SelectCommand3 As String = "Select * FROM Services WHERE ServiceType = 'Blind'"

Dim myConnection As OleDbConnection = New OleDbConnection(connStr)

Dim myDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter(SelectCommand1, myConnection)
Dim myDataAdapter2 As OleDbDataAdapter = New OleDbDataAdapter(SelectCommand2, myConnection)
Dim myDataAdapter3 As OleDbDataAdapter = New OleDbDataAdapter(SelectCommand3, myConnection)

myDataAdapter1.Fill(myDataSet1, "Divisions")
myDataAdapter2.Fill(myDataSet2, "Customers")
myDataAdapter3.Fill(myDataSet3, "Services")

ddDivisions.DataSource = myDataSet1
ddDivisions.DataMember = "Divisions"
ddDivisions.DataTextField = "DivisionNo"
ddDivisions.DataValueField = "Division"
ddDivisions.DataBind()

ddlCustomers.DataSource = myDataSet2
ddlCustomers.DataMember = "Customers"
ddlCustomers.DataTextField = "CustomerName"
ddlCustomers.DataValueField = "CustomerID"
ddlCustomers.DataBind()

ddlBlinds.DataSource = myDataSet3
ddlBlinds.DataMember = "Services"
ddlBlinds.DataTextField = "Cat2"
ddlBlinds.DataValueField = "ServiceType"
ddlBlinds.DataBind()

End If



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Dropdownlist moves back to Index=0

Loop 2 MIDI's back to back on web www.computing.net/answers/programming/loop-2-midis-back-to-back-on-web-/5497.html

Batch: accented characters problem www.computing.net/answers/programming/batch-accented-characters-problem/16760.html

Map Network Drive Back to Original www.computing.net/answers/programming/map-network-drive-back-to-original/18625.html