|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ok, I get the following:
myHT.Add("key1", "value1"); myHT.Add("key2", "value2"); lb.DataSource = myHT; lb.DataTextField = "Key"; lb.DataValueField = "Value"; lb.DataBind(); Works fine. Now, I want to do the same kind of thing, except that the Hashtable will store objects instead of simple strings: obj1.Name = "myName1"; obj1.Value = "myValue1"; obj1.Tag = "myTag1"; obj2.Name = "myName2"; obj2.Value = "myValue2"; obj2.Tag = "myTag2"; myHT.Add("key1", obj1); myHT.Add("key2", obj2); lb.DataSource = myHT; lb.DataTextField = "Key"; lb.DataValueField = "Value"; lb.DataBind(); ...only I want to do something akin to: lb.DataValueField = "Value.Tag"; a) obj's must be [Serializable] - check. b) overriding obj.ToString() to return _tag; will work I just want to know, how can one force a list box in data binding to utilize the object properties the 'correct' way? Any ideas? Thanks, |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > DataBind ListBox w/ Hashtable-objects |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|