'Object reference not set to an instance of an object. when using for loop to store data in a grid view to a string
Private Sub btnupload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupload.Click
Dim Data As String = ""
' Dim i As Integer = 0
' For Each i As DataGridViewRow In DataGridView1.Rows
For i As Integer = 0 To DataGridView1.RowCount - 1
'For Each i As Integer =0 to DataGridView1.
Data = DataGridView1.Rows(i).Cells(0).Value.ToString + "~" + DataGridView1.Rows(i).Cells(1).Value.ToString + "~" + DataGridView1.Rows(i).Cells(2).Value.ToString + "~" + DataGridView1.Rows(i).Cells(3).Value.ToString + "*"
Next
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
