Solved

Help with parsing and loading data in listbox

Posted on 2012-04-04
7
228 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 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