troubleshooting Question

Help with saving data to Datatable and displaying data in listbox

Avatar of vcharles
vcharles asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution430 ViewsLast Modified:
Hi,

I am using the code below to include data in a Datatable to display in a listbox, problem is
eventhough the dta is found in two records (part B), my DataTable contains 5 rows instead
of two rows, apparently I am getting a row for each natch but I need a row for each record. Based on data in Part B, my Datatable should contain:

Row1 102,104,105
Row2 102,104

Instead I am getting
Row1 102,
Row2 104
Row3 105
Row4 102
Row5 104


The code below gives me the following error:

"Complex DataBinding accepts as a data source either an IList or an IListSource."

For example if C1Ctry.SelectedValue.ToString = 1
For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Ctry_ID='" & C1Ctry.SelectedValue.ToString & "']")
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText

‘Retreive data

  For Each xnNSN As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[contains('," & NSNID & ",', concat(',', NSN_ID, ','))]")
                NSNID2 = xnNSN.SelectSingleNode("NSN_ID").InnerText
                Name = xnNSN.SelectSingleNode("NSN").InnerText
                dtNSN.Rows.Add({NSNID2, Name})
                utubeNSN = "," & Name
            Next

          ‘Display data
C1NSN.Items.Clear()
C1NSN.DataSource = dtNSN.Rows(0) ' Error
 C1NSN.DisplayMember = "NSN"
 C1NSN.ValueMember = "NSN_ID"
Next


Part B
<LinkA>
    <LinkAID>1</LinkAID>
    <crty_ID>1</ctry_ID>
       <NSN_ID>1,2,5</NSN_ID>
      </LinkA>
<LinkA>
    <LinkAID>2</LinkAID>
    <ctry_ID>1</ctry_ID>
     <NSN_ID>1,2</NSN_ID>
     </LinkA>


How do I modify the code to obtain the data in the right number of rows and How do I move to the next row to display the right record?

Thanks,

Victor
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros