Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
Cannot loop through cells
posted

I want to loop through the cells when the customer passes it back to me. I may have a different number of cells depending on the query execution, so I want to loop from the first cell to however many cells I have:

 

Private Sub HandleNotes(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles GridView2.UpdateRowBatch

Dim Str As String, cellCount As Integer
Str = "Hello: "
cellCount = CInt(e.Row.Cells.Count)
For i As Integer = 1 To cellCount Step 1
    Str = Str & e.Row.Cells(i).Text 'Error Thrown Here: Object reference not set to an instance of an object
Next

If I swap out the i in the cell count with an actual number, it works just fine:
Str = Str & e.Row.Cells(2).Text

If I just print out the loop control variable i, it prints numbers you would expect. I have no idea why it is throwing this error.

TIA.