dropdownlist's Datavaluefield is not working
- by Ranjana
i am getting the datas from database and storing in a collectionobject. The collectionobj contains the Datas 'Name' and 'ID'.
My code:
<asp:dropdownlist id="dropdown1" runat="server" DataTextField="Name" DataValueField="ID"/>
collectionobj=objbs.GetNAmes()
for intloop as integer in Collectionobj.Count.Rows-1
dropdown.Items.Add( Collectionobj.Items(intloop).Name)
dropdown.DataValueField=Collectionobj.Items(intloop).ID
Next
dropdown.DataBind()
Im getting the Value binded in the dropdown as "Names" . when i select the dropdown i need to pass the respective ID of that name.
But when I assign the
Dim strid as String=dropdown1.DataValueField
The dropdown1.DataValueField is holding the id of last name binded in the dropdown.it is not taking the id which im selecting n the dropdown..
Any suggestion..........