RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3282 | Replies: 2
Reply
Join Date: Jul 2005
Posts: 12
Reputation: ozeona is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ozeona's Avatar
ozeona ozeona is offline Offline
Newbie Poster

Help About Dynamic Hashtable

  #1  
Jul 12th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Seattle, WA
Posts: 53
Reputation: senexom is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: About Dynamic Hashtable

  #2  
Jul 19th, 2005
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.
Reply With Quote  
Join Date: Jul 2005
Posts: 12
Reputation: ozeona is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ozeona's Avatar
ozeona ozeona is offline Offline
Newbie Poster

Re: About Dynamic Hashtable

  #3  
Jul 19th, 2005
ooh yea i figured it out. thanks a lot!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:51 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC