Solved

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

Posted on 2004-09-09
7
441 Views
Last Modified: 2008-03-17
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
Comment
Question by:tbaseflug
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12021234
what are you doing after you split them, how are they stored in your db field?
0
 

Author Comment

by:tbaseflug
ID: 12021283
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
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12021329
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 17

Expert Comment

by:AerosSaga
ID: 12021345
0
 

Author Comment

by:tbaseflug
ID: 12021357
Any idea how I would set the selections to a listbox to from something like that?
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 500 total points
ID: 12021368
Once you have them to strings insert them like this:

ddl.Items.Insert(0, MyStringVariable);
0
 

Author Comment

by:tbaseflug
ID: 12027063
Let me give it a shot and will let you know as soon as I am done - thanks!!!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question