.net - Binding a listbox with value and text -


i creating listcollection this:

dim rislist new listitemcollection         dim cuser new clsuser()         dim ds dataset = cuser.getuserris(1)         each row in ds.tables(0).rows             dim li new listitem             li.text = clookup.getxname(row.item("xcode"))             li.value = row.item("xcode")             rislist.add(li)         next 

i need bind dropdownlist it

  ddlris.datasource = rislist         ddlris.databind() 

however text , value in drop down, both show text. when debug above code li.value = row.item("riscode") shows code correctly, why not reflect when try bind dropdown list?

why don't add directly listbox/dropdownlist workaround, way should work though.

dim rislist new listitemcollection dim cuser new clsuser() dim ds dataset = cuser.getuserris(1) each row in ds.tables(0).rows     dim li new listitem     li.text = clookup.getxname(row.item("xcode"))     li.value = row.item("xcode")     ddlris.items.add(li) next 

and can access text , value by: (respectively)

dim txt1 string, val1 string txt1 = ddlris.selecteditem.text val1 = ddlris.selecteditem.value 

hope helps.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -