Datalist - Listbox: Parse CSV string/value and pre-select multiple items

I have a listbox and am allowing the user to make multiple selections from it - the selected values are combined and concatenated via the below code and then insterted into a single SQL column.  

        Dim str3() As String
        Dim strHardware As String
        For i As Integer = 0 To lbServersHardwareAffected.Items.Count - 1
            If lbServersHardwareAffected.Items(i).Selected = True Then
                strHardware = strHardware + lbServersHardwareAffected.Items(i).Text
                strHardware = strHardware + ", "
            End If
        Next
        If Not strHardware = "" Then
            strHardware = Left(strHardware, Len(strHardware) - 2)
        End If
        str3 = strHardware.Split(CType(",", Char))

What I am trying to do is to grab the results from the SQl column (e.g. = value1, value2, value3) and setup a listbox in a datalist to pre-select the values.  I am using a Dataset and a store rpocedure to select and return the data from the database.  Need it in VB.NET if possible -
tbaseflugAsked:
Who is Participating?
 
AerosSagaConnect With a Mentor Commented:
Once you have them to strings insert them like this:

ddl.Items.Insert(0, MyStringVariable);
0
 
AerosSagaCommented:
what are you doing after you split them, how are they stored in your db field?
0
 
tbaseflugAuthor Commented:
They are actually combined and then stored in the db field as:

value1, value2, value3

What I need to do is split them from the db
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
AerosSagaCommented:
I use this to split csv from my sql server for a csv of users:

HttpContext.Current.User = New GenericPrincipal(User.Identity, Split(authTicket.UserData, ","))
0
 
tbaseflugAuthor Commented:
Any idea how I would set the selections to a listbox to from something like that?
0
 
tbaseflugAuthor Commented:
Let me give it a shot and will let you know as soon as I am done - thanks!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.