J
J055
Hi
I have a GridView which includes the ability to delete rows. This works fine
accept for when a naughty user decides to refresh the browser thereby
posting the same delete command instruction. The problem with this is that
the refresh will either delete another record or generate an exception,
something like this:
An error has occurred because a control with id
'ctl00$Main$UserGrid$ctl11$ctl00' could not be located
The first scenario is unwelcome but the second is very nasty because it's
then very difficult for the user to remedy the situation. It's easy to see
why this is happening because the post data for the delete command contains
the index of the row and then matches it to a CommandArgument held in the
viewstate (I think). In my case the CommandArgument contains the PrimaryKey
ID of the record being deleted so when I refresh the page I am deleting the
record which takes the previous record's place, if one exists, else I get
the above error.
Is there a way to handle this better? How do I make this more robust? What
is actually happening in the page life cycle and the viewstate when I delete
a record?
In the old days you would sent the record ID with the get/post request. Why
can't we make the GridView do this?
Cheers
Andrew
I have a GridView which includes the ability to delete rows. This works fine
accept for when a naughty user decides to refresh the browser thereby
posting the same delete command instruction. The problem with this is that
the refresh will either delete another record or generate an exception,
something like this:
An error has occurred because a control with id
'ctl00$Main$UserGrid$ctl11$ctl00' could not be located
The first scenario is unwelcome but the second is very nasty because it's
then very difficult for the user to remedy the situation. It's easy to see
why this is happening because the post data for the delete command contains
the index of the row and then matches it to a CommandArgument held in the
viewstate (I think). In my case the CommandArgument contains the PrimaryKey
ID of the record being deleted so when I refresh the page I am deleting the
record which takes the previous record's place, if one exists, else I get
the above error.
Is there a way to handle this better? How do I make this more robust? What
is actually happening in the page life cycle and the viewstate when I delete
a record?
In the old days you would sent the record ID with the get/post request. Why
can't we make the GridView do this?
Cheers
Andrew