jezz jezz - 1 year ago 74 Question

For Each Gridview not working properly

Can you help me on my for each loop it only saves the first row many times of the Gridview on my database. Can you please help me if what's wrong on my code. Thanks in advance.

here is my code

Using _adTransPlatts As New TradingTransactionRepository

For Each row As GridViewRow In
GridView1.Rows_adTransPlatts.AddPlatts(GridView1.Rows(0).Cells(1).Text, GridView1.Rows(0).Cells(2).Text, GridView1.Rows(0).Cells(3).Text)
End Using

Answer Source

Change GridView1.Rows(0) by currentRow

 For Each currentRow As GridViewRow In GridView1.Rows
        _adTransPlatts.AddPlatts(currentRow.Cells(1).Text, currentRow.Cells(2).Text, currentRow.Cells(3).Text)

GridView1.Rows(0) refers always to the first row

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download