T
tshad
I have a string that I read from my database: 1|8|5620|541
These are all values in my ListBox. I want to select each of these items (4
of them - but could be many more). At the moment I am doing the following:
Dim a() As String
Dim j As Integer
a = JobCategoriesSelected.Split("|") ' Where
JobCategoriesSelected is set to 1|8|5620|541
For j = 0 To a.GetUpperBound(0)
trace.warn("string = " & a(j))
for each item as ListItem in JobCategories.items
if item.value = a(j) then
item.selected = true
end if
next
Next
The problem is that for each Item I am selecting, I am having to go through
the list to find the value that matches the one I want to set. In this
case, it would have to go through the list 4 times.
Is there some kind of a way to do it in one line where you say something
like set the listitem that is equal to my value to selected?
Thanks,
Tom
These are all values in my ListBox. I want to select each of these items (4
of them - but could be many more). At the moment I am doing the following:
Dim a() As String
Dim j As Integer
a = JobCategoriesSelected.Split("|") ' Where
JobCategoriesSelected is set to 1|8|5620|541
For j = 0 To a.GetUpperBound(0)
trace.warn("string = " & a(j))
for each item as ListItem in JobCategories.items
if item.value = a(j) then
item.selected = true
end if
next
Next
The problem is that for each Item I am selecting, I am having to go through
the list to find the value that matches the one I want to set. In this
case, it would have to go through the list 4 times.
Is there some kind of a way to do it in one line where you say something
like set the listitem that is equal to my value to selected?
Thanks,
Tom