VB.net DatGridView problem populating multiple cells

Hi
I am using the following code to load a DataGridView.
If I then run the single line    Me.dgvBank.Rows(628).Cells(5).Value = 63
it works, but if I loop through and try to populate multiple lines they don't hold the value
Not sure why

    Public oSQLAdapterBank As SqlDataAdapter
    Public oSQLTableBank As New DataTable
Sub Load
        Dim sSQL As String
            sSQL = "Select * From BANK"

          Me.cmbSQLTables.Visible = True
                oSQLTableBank.Clear()
                Dim connection As New SqlConnection(Form_Settings.lblConnectionString.Text)
                oSQLAdapterBank = New SqlDataAdapter(sSQL, connection)
                oSQLAdapterBank.Fill(oSQLTableBank)
                Me.dgvBank.DataSource = oSQLTableBank
End Sub
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun KlineLead Software EngineerCommented:
Where are you looping through the grid? This code only loads the DataGridView with data using your SQL statement.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
I gather the row index and the integer that I want to populate the cell with then populate as follows
            Dim arrSplitRows As Object = Split(strRowIndices, ",")
            Dim arrSplitLinkIDs As Object = Split(strLinkIDs, ",")
            Dim oRowIndex As Long
            Dim oLinkID As Long

            For i = 0 To UBound(arrSplitRows)
                'If i = 77 Then Stop
                oRowIndex = CLng(arrSplitRows(i))
                oLinkID = CLng(arrSplitLinkIDs(i))
                If IsNumeric(oRowIndex) = True And IsNumeric(oLinkID) = True Then
                    Try
                        Me.dgvBank.Rows(oRowIndex).Cells(5).Style.BackColor = Color.Blue
                        Me.dgvBank.Rows(oRowIndex).Cells(5).Value = oLinkID
                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try

                End If

            Next
0
ChloesDadCommented:
How many elements are there in arrsplitrows and are all the elements numbers?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi. There are around 65 elements and they are all numbers
0
ChloesDadCommented:
OK, there is nothing that appears wrong. Have you stepped through the code and looked at the values of oRowIndex and oLinkID as the code executes?

Do the values appear and then get overwritten? If that's the case then this code is probably right, and something else is overwriting your values with something else.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. Sorry about the late reply
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.