dropdown list + selecting data

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi all

Have a drop down list on my webform, which is binded to a dataset using the following code.
dim dsDataSet as new dataset = x.getAccess
ddAccess.datasource = dsDataSet
ddAccess.dataTextfield = "Access_name"
ddAccess.dataBind()
This code loads the data into the dropdown list no problem and the list works away. The data in the dropdown list is "Guest", "User", "Admin"

Now the problem occures when i reload data from the database, in that when i want to select the users access level i go
ddAccess.selecteditem.text = dataString(2)
Take for example the data i am loading is John, Admin, 23423423, So i put John and 23423423 into 2 seperate textboxes, however when i go and select the access level, what happens is that the "Guest" entry is replaces by the "Admin" entry so that the dropdown list now consists of "Admin", "User", and "Admin".

Used to be able to get ddAccess.selectedValue = dataString(2)

Any suggestions.

Mike
 
Put the following before the DataBind :
Visual Basic:
ddAccess.DataValueField = "Access_name"

And now .SelectedValue = "something" will now work correctly
 
Back
Top