Hi,
Due to the complexity of the data, I have to build up the datatable manually and then bind it to a gridview. The process is listed below:-
1. Build data into 2d array array
2. Loop through each row in the array, building a Datarow and adding the datarow to the datatable.
3. Binding the datatable to the gridview.
This works perfect when viewing the data, however I can not update any rows. It gets into the edit mode fine, but when I click update it gives the following error:-
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
The code is listed below:-
Dim UpdateValues(20) As String
Dim UpdateValuesCount As Integer = 0
For CellCount As Integer = 0 To 18
Dim DataControlFieldCell As DataControlFieldCell = TryCast(gvPrincipalPosition.Rows(e.RowIndex).Cells(CellCount), DataControlFieldCell)
gvPrincipalPosition.Columns(CellCount).ExtractValuesFromCell(e.NewValues, DataControlFieldCell, DataControlRowState.Edit, True)
Next
It dies on line 5. Any ideas would be very much appreciated!
Due to the complexity of the data, I have to build up the datatable manually and then bind it to a gridview. The process is listed below:-
1. Build data into 2d array array
2. Loop through each row in the array, building a Datarow and adding the datarow to the datatable.
3. Binding the datatable to the gridview.
This works perfect when viewing the data, however I can not update any rows. It gets into the edit mode fine, but when I click update it gives the following error:-
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
The code is listed below:-
Dim UpdateValues(20) As String
Dim UpdateValuesCount As Integer = 0
For CellCount As Integer = 0 To 18
Dim DataControlFieldCell As DataControlFieldCell = TryCast(gvPrincipalPosition.Rows(e.RowIndex).Cells(CellCount), DataControlFieldCell)
gvPrincipalPosition.Columns(CellCount).ExtractValuesFromCell(e.NewValues, DataControlFieldCell, DataControlRowState.Edit, True)
Next
It dies on line 5. Any ideas would be very much appreciated!