Link to home
Start Free TrialLog in
Avatar of Fraser_Admin
Fraser_AdminFlag for Canada

asked on

GridView RowCommand Pagechanged

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?
ASKER CERTIFIED SOLUTION
Avatar of cmhunty
cmhunty

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fraser_Admin

ASKER

there is no build in functionality which allows you to get the current row on the current page?
in the rowcommand event it uses the old value.  so if page 1 is display and then i click on page 2 it is firing the rowcommand event and the pageindex = 0, when really it should be 1.  so i guess that won't work.

is there anyways to have in there if the rowcommand event is fired due to a page break then skip it or something?
oops i mean due to a page change not a page break.
any ideas here?