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
301 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
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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