T
tom c
I have a dropdown list box on an ASP.Net 1.1 webform. I populate it
from a dataset in code. Everything looks fine and I can see all the
values in the dropdownlist. I can select a value and I see that new
selected value in the list box. However, when I look for the values in
code, I see the original value from the list box. The one that was
loaded first and showed up before I selected a new one.
This is the code I use to look at the value:
c = Me.DropDownListHotels.SelectedValue.ToString
d = Me.DropDownListHotels.SelectedItem.ToString
k = Me.DropDownListHotels.SelectedItem.Text
This is the code I use to load the list box:
Sub LoadHotels()
Dim password, firstname, userid, loginid, sql As String
Dim cn As New
OleDb.OleDbConnection(Mod1.buildConnectionString("CIADSTATViewer.mdb"))
sql = "SELECT name, propertycode FROM hotels)"
Dim da As New OleDb.OleDbDataAdapter(sql, cn)
Dim ds As DataSet = New DataSet("Users")
da.Fill(ds)
cn.Close()
' Populate drop down list
Me.DropDownListHotels.DataSource = ds.Tables(0)
Me.DropDownListHotels.DataTextField = "name"
Me.DropDownListHotels.DataValueField = "propertycode"
Me.DropDownListHotels.DataBind()
Catch ex As Exception
Mod1.ErrorMessage(ex, "LoadHotels")
End Try
End Sub
from a dataset in code. Everything looks fine and I can see all the
values in the dropdownlist. I can select a value and I see that new
selected value in the list box. However, when I look for the values in
code, I see the original value from the list box. The one that was
loaded first and showed up before I selected a new one.
This is the code I use to look at the value:
c = Me.DropDownListHotels.SelectedValue.ToString
d = Me.DropDownListHotels.SelectedItem.ToString
k = Me.DropDownListHotels.SelectedItem.Text
This is the code I use to load the list box:
Sub LoadHotels()
Dim password, firstname, userid, loginid, sql As String
Dim cn As New
OleDb.OleDbConnection(Mod1.buildConnectionString("CIADSTATViewer.mdb"))
sql = "SELECT name, propertycode FROM hotels)"
Dim da As New OleDb.OleDbDataAdapter(sql, cn)
Dim ds As DataSet = New DataSet("Users")
da.Fill(ds)
cn.Close()
' Populate drop down list
Me.DropDownListHotels.DataSource = ds.Tables(0)
Me.DropDownListHotels.DataTextField = "name"
Me.DropDownListHotels.DataValueField = "propertycode"
Me.DropDownListHotels.DataBind()
Catch ex As Exception
Mod1.ErrorMessage(ex, "LoadHotels")
End Try
End Sub