Hi,
I have set the content of a listbox through databinding.
myListBox.DataSource = myDataSource
myListBox.DataTextField = "column01"
myListBox.DataValueField = "column02"
myListBox.DataBind()
I have then set the selected index of the listbox using a loop
Dim myValue As Integer = [I]someValue[/I]
Dim myListItem As ListItem = New ListItem
For Each myListItem In myListBox.Items
If myListItem.Value = myValue Then
myListItem.Selected = True
End If
Next
It seems a little strange that you can so easily define a datasource but have to resort to a loop to define the selected index.
Is there no way to define the selected index when the datasource is bound? What if I have multple selections to define, would I have to expand my loop to set these?
Thanks,
Fido.