hi

recently, i realise theres such thing as Hashtable that are allow listbox to retrieve url when clicked. However, as i find out more, i realise most examples i saw are static. As in

dim mycountries=New Hashtable
  mycountries.Add("N","Norway")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")

is there any way to retrieve this list from database instead of coding it like that?

i tried doing so, but it gave me a "Public member 'DataSource' on type 'Hashtable' not found." error.

cmdSelect = New OdbcCommand( "SELECT IMG_TITLE, IMG_LINK FROM worklist", conODBC)


DApt.selectCommand = cmdSelect
DApt.Fill(dsSet, "worklist")

Dim linkrd = new Hashtable
linkrd.DataSource = dsSet.Tables("worklist")
linkrd.DataBind()

linklist.DataSource = linkrd
linklist.DataTextField="img_title"
linklist.DataValueField="img_link"
linklist.DataBind()

can anyone guide me on this?
thanks a lot

Recommended Answers

All 2 Replies

You almost have it, use "Key", or "Value" for datasource assignment and a DataReader to populate values from database query...

Dim linkrd = New HashTable()

While reader.Read()
   linkrd.Add(reader.GetString(0), reader.GetString(1))
End While

linklist.DataSource = linkrd
linklist.DataTextField = "Value"
linklist.DataValueField = "Key"
linklist.DataBind()

PS: I'm not a VB developer so if I got something mixed up, I'm sure you'll figure it out.

ooh yea i figured it out. thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.