Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

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 -
0
tbaseflug
Asked:
tbaseflug
  • 4
  • 3
1 Solution
 
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
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tbaseflugAuthor Commented:
Any idea how I would set the selections to a listbox to from something like that?
0
 
AerosSagaCommented:
Once you have them to strings insert them like this:

ddl.Items.Insert(0, MyStringVariable);
0
 
tbaseflugAuthor Commented:
Let me give it a shot and will let you know as soon as I am done - thanks!!!!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now