Link to home
Start Free TrialLog in
Avatar of tbaseflug
tbaseflugFlag for United States of America

asked on

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 -
Avatar of AerosSaga
AerosSaga

what are you doing after you split them, how are they stored in your db field?
Avatar of tbaseflug

ASKER

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
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, ","))
Any idea how I would set the selections to a listbox to from something like that?
ASKER CERTIFIED SOLUTION
Avatar of AerosSaga
AerosSaga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Let me give it a shot and will let you know as soon as I am done - thanks!!!!