Solved

Help with parsing and loading data in listbox

Posted on 2012-04-04
7
226 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

19 Experts available now in Live!

Get 1:1 Help Now