GridView RowCommand Pagechanged
Posted on 2007-11-28
I have a griidview control. When the user changes the selected row on the gridview I change a formview to display the information as well (allowing the user to edit the row via a formview). I do this in the rowcommand event of the gridview. Linking the formview to the gridview row by e.CommandArgument in the rowcommand event. I needed to do it like this so it picked up the newly changed row.
Now when I have my gridview do paging, it has the commandargument as the rowvalue of the dataset as opposed to the rowvalue of the displayed grid. so then it fails when i try to get the row from the grid.
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = gvSample.Rows(index)
For example: For a test I set the rows per page to be 2. My total rows are 3. So when i am on page 1 no problem at all. When I go to page 2 I get an error. When i print out the value of index it is 2.
It then throws an error since there is only 1 row on that gridview page, when I try to Dim Row above.
Any ideas here?