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

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.

This article has been dead for over six months. Start a new discussion instead.