Solved

Help with loopingf through GridView and retreiving IDs from xml file or creating new IDs if data does not exist

Posted on 2012-12-27
3
303 Views
Last Modified: 2012-12-27
Hi,

I am using the code below to loop through a listbox to  retreive existing ID(Part A) or create new IDs (Part B).

How do I modify it for a GridView (Windows App, VS 2010)


For x As Integer = 0 To C1NSN.Items.Count - 1

'PartA:
                If CheckForNSNFix.Contains(C1NSN.Items(x).ToString) Then
                    For Each xnLink As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[NSN='" & C1NSN.Items(x).ToString & "']")
                        NSN_ID = xnLink.SelectSingleNode("NSN_ID").InnerText
                        If NSN_ID <> "" Then
                            CD = NSN_ID
                            If u > 0 Then
                                num1 = num1 & "" & CD & ","
                            Else
                                num1 = CD & ","
                            End If
                            u = u + 1
                        End If
                    Next
                End If
            Next



'Part B:
            'Assign ID to data not already in XML file
            For x As Integer = 0 To C1NSN.Items.Count - 1
                If Not CheckForNSNFix.Contains(C1NSN.Items(x).ToString) Then
                    Dim xNew As XElement = New XElement(xtable)
                    xNew.Add(New XElement(xid, num))
                    xNew.Add(New XElement(curXYZ, C1NSN.Items(x)))
                    MyFix.Root.Add(xNew)
                    MyFix.Save((Application.StartupPath + "\App_Data\" & curXYZ & ".xml"))
                    If uu > 0 Then
                        num2 += num & ","
                    Else
                        num2 = num & ","
                    End If
                    uu = uu + 1
                    num = num + 1
                End If

            Next
            searchIdNSN = num1 & num2
0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38724336
Assuming C1NSN is your gridview, simply replace C1NSN.Items with C1NSN.Rows
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38724377
Btw, i assumed that your id is in 1st column, otherwise u need to specify the column as well:
So instead of C1NSN.Items(x).ToString)
Use this:
C1NSN.Items(x)(column-index).ToString()

Or by column name:
C1NSN.Items(x)("Column-name").ToString()
0
 

Author Closing Comment

by:vcharles
ID: 38724806
Thank You!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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