Help please with this

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
The following will only insert one row and not all the rows

Dim gvr As GridViewRow
Dim gv As GridView = Me.GridView1
Dim fileCol As New Generic.List(Of FileEntry)
Dim myFile As New FileEntry

For Each gvr In gv.Rows

With myFile
.Location = gvr.Cells(0).Text
.Name = gvr.Cells(1).Text
.Date = "2006-01-01"
.Year = gvr.Cells(7).Text

...

End With

fileCol.Add(myFile)

Next gvr


rf.InsertReceivingFile(fileCol)

When I try to break at rf.InsertReceivingFile(fileCol) there is only one
row in the collection. Am I missing something?

Thanks
 
That's because you are working with the same "myFile" on every trip through
your loop.

Create a new one for each trip through the loop (e.g., create it inside the
loop), and it should work OK.
 
Back
Top