Avatar of vcharles
vcharles
 asked on

Help with unbounding a Grid

Hello,

I am loading my grid with code in Part A, but when trying to save data entered in code in Part B I receive the following error:

Not supported when the grid is bound

on line: For x As Integer = 0 To C1NSN.Rows.Count - 1

How do you unbound the grid or fix this error?

Part A:

 Dim NSN As New DataSet
        NSN.ReadXml(Application.StartupPath + "\App_Data\Blank.xml")
        C1NSN.DataSource = NSN.Tables(0)



Part B:

    For x As Integer = 0 To C1NSN.Rows.Count - 1
                If CheckForNSNFix.Contains(C1NSN.Rows(x).ToString) Then
                    For Each xnLink As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[NSN='" & C1NSN.Rows(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
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
vcharles

8/22/2022 - Mon
vcharles

ASKER
Help!
Nasir Razzaq

Is C1NSN a DataGridView?
vcharles

ASKER
C1NSN is from componentOne (TrueDBGrid), but I thinnk the solution for the DataGridView would also apply since they have many similar features.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
vcharles

ASKER
Currently do not have access to my application, I will try it later and get back to you.
Thanks.
vcharles

ASKER
Hi,
I still receive error message "Not supported when the Grid id bound"
Nasir Razzaq

On same line?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
vcharles

ASKER
Yes.
Paul MacDonald

If you step through the code, what is the value of C1NSN.Rows.Count?  Alternately, you could do something like...
     Dim x as Integer = C1NSN.Rows.Count
...to see the value
Paul MacDonald

Also, what if you try:

   ...
     For x As Integer = 0 To C1NSN.Splits(0).Rows.Count - 1
   ...
Your help has saved me hundreds of hours of internet surfing.
fblack61
vcharles

ASKER
Hi,

Post with C1NSN.RowCount  works, modified to C1NSN.RowCount  - 1

Thank you for all you comments.

Victor