Solved

Help with parsing and loading data in listbox

Posted on 2012-04-04
7
227 Views
Last Modified: 2012-04-04
Hello,

The data in my xml file is in the following format:

<Data>1-Data; 2-data; 3-Data</Data>

How do I load the data in a listbox in the following format:

1-Data
2-Data
3-Data

Victor
0
Comment
Question by:vcharles
  • 5
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
zofcentr earned 500 total points
ID: 37804879
Try this way.
1. Load XML using  XMLDocument example here: http://vbnetsample.blogspot.com/2007/07/read-xml-content-by-xmldocument.html.2.
2. Get inner text of your node into string  - example under above document link also.
3. Split this string using split funciton of String class - example here http://www.dotnetperls.com/split-vbnet.
4. Assign array returned by Split function to your listbox.
0
 

Author Comment

by:vcharles
ID: 37804918
Thanks, will try it an get back to you.
0
 

Author Comment

by:vcharles
ID: 37805310
Hello,

When I try to pass the data from my textbox (1-Data; 2-Data; 3-Data) to the listbox using the code below,

 C1NSN.Text = dtNSN.Rows(0).Item("NSN")
        Dim tmp() As String = C1NSN.split(";")
        For i As Integer = 0 To tmp.Length - 1
            ListBox1.Items.Add(tmp(i))
        Next

I receive the following error:

'split' is not a member of 'System.Web.UI.WebControls.TextBox'.

How do  i fix this error?

Thanks,

Victor
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:vcharles
ID: 37805319
Hi,

I got it to work with

Dim tmp() As String = C1NSN.Text.Split(";")

Will get back to you.
0
 

Author Comment

by:vcharles
ID: 37805334
Can This also be done with a GridView instead of a Listbox?

C1NSN.Text = dtNSN.Rows(0).Item("NSN")
        Dim tmp() As String = C1NSN.Text.split(";")
        For i As Integer = 0 To tmp.Length - 1
            'ListBox1.Items.Add(tmp(i))
             GridView1.??????
        Next
0
 
LVL 3

Expert Comment

by:zofcentr
ID: 37805594
Yes it can be done with grid.
Depending on grid you are using (datagrid or datagridview) you have to add column and then add rows with specific values in particular column.

HEre you can find some examples of using datagridview: http://www.dotnetperls.com/datagridview-vbnet.
0
 

Author Comment

by:vcharles
ID: 37806017
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now