B
Ben Mann
Hi There,
Ive got an ASP .Net page with a listbox element.
This listbox element is databound to a sorted list filled with keys and
values from the database:
dbReader = lookupUtil.getLookup("country", 0, 0,
ConfigurationSettings.AppSettings("DSN"))
If dbReader.HasRows Then
countries = New SortedList
countries .Add("", "Please Select")
While dbReader.Read
countries .Add(CStr(dbReader.GetInt32(0)), dbReader.GetString(1))
End While
End If
lstCountry.DataSource = countries
lstCountry.DataValueField = "key"
lstCountry.DataTextField = "value"
lstCountry.DataBind()
Im using a sortedlist because the documentation led me to believe that the
items will come out of the list int he same order that they went in (like an
array), but have key/value pairs to store both id's and values in the data
structure.
I know that the information is coming out ordered correctly from the DB, but
the listbox values are completely jumbled up.
Am i missing a setting for the SortedList as it seems to be behaving like a
HashTable at the moment.
Many Thanks.
Ben Mann.
Ive got an ASP .Net page with a listbox element.
This listbox element is databound to a sorted list filled with keys and
values from the database:
dbReader = lookupUtil.getLookup("country", 0, 0,
ConfigurationSettings.AppSettings("DSN"))
If dbReader.HasRows Then
countries = New SortedList
countries .Add("", "Please Select")
While dbReader.Read
countries .Add(CStr(dbReader.GetInt32(0)), dbReader.GetString(1))
End While
End If
lstCountry.DataSource = countries
lstCountry.DataValueField = "key"
lstCountry.DataTextField = "value"
lstCountry.DataBind()
Im using a sortedlist because the documentation led me to believe that the
items will come out of the list int he same order that they went in (like an
array), but have key/value pairs to store both id's and values in the data
structure.
I know that the information is coming out ordered correctly from the DB, but
the listbox values are completely jumbled up.
Am i missing a setting for the SortedList as it seems to be behaving like a
HashTable at the moment.
Many Thanks.
Ben Mann.