Help with unbounding a Grid

vcharles
vcharles used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Help!
Most Valuable Expert 2012
Top Expert 2014

Commented:
Is C1NSN a DataGridView?

Author

Commented:
C1NSN is from componentOne (TrueDBGrid), but I thinnk the solution for the DataGridView would also apply since they have many similar features.
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Most Valuable Expert 2012
Top Expert 2014
Commented:
They are different in this case. What happens if you change

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

to

For x As Integer = 0 To C1NSN.RowCount

Author

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

Author

Commented:
Hi,
I still receive error message "Not supported when the Grid id bound"
Most Valuable Expert 2012
Top Expert 2014

Commented:
On same line?

Author

Commented:
Yes.
Paul MacDonaldDirector, Information Systems

Commented:
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 MacDonaldDirector, Information Systems

Commented:
Also, what if you try:

   ...
     For x As Integer = 0 To C1NSN.Splits(0).Rows.Count - 1
   ...

Author

Commented:
Hi,

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

Thank you for all you comments.

Victor

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial