Instead of assigning Datagridview.datasource =MyDataTable , I want to read DataTable rows one by one into Datagridview (Due to some reasons). I tried as under but it shows the last row only.
can any body help pls?
can any body help pls?
VB.NET:
Private Sub BtnShowBills_Click(sender As System.Object, e As System.EventArgs) Handles BtnShowBills.Click
GetConnect()
Using cmd As New SqlCommand("USP_ShowVendorDetailBill", Conn)
cmd.CommandType = CommandType.StoredProcedure
Conn.Open()
cmd.Parameters.AddWithValue("@PurBillNo", TextBox1.Text)
Using reader As SqlDataReader = cmd.ExecuteReader
Dim dt As New DataTable
Dim i As Integer = 0
dt.Load(reader)
For i = 0 To dt.Rows.Count - 1
PurchaseGrid.Rows.Item(0).Cells(0).Value = dt.Rows(i)("ProductID")
PurchaseGrid.Rows.Item(0).Cells(1).Value = dt.Rows(i)("PurDescription")
PurchaseGrid.Rows.Item(0).Cells(2).Value = dt.Rows(i)("PurQty")
PurchaseGrid.Rows.Item(0).Cells(3).Value = dt.Rows(i)("PurRate")
PurchaseGrid.Rows.Item(0).Cells(4).Value = dt.Rows(i)("Amount")
Next
End Using
End Using
End Sub