F
Froefel
A common question, but I haven't found an answer on the net yet, so
maybe someone from the group can give me some pointers.
I have a webform with a gridview control that has a ButtonField column
(button is an icon). When the icon is clicked, the OnRowCommand is
fired with CommandName "DeleteProject".
All this is working fine, except that, upon clicking the icon, the
order of events is as follows:
1. Page_Load (with IsPostback == true)
2. gvProjects_RowCommand (with CommandName == "DeleteProject"
and CommandArgument == the index of the row; this is where the project
actually gets deleted through a stored procedure)
3. gvProjects_RowDataBound (nothing special happens here -- only
the icon is hidden for projects that the user doesn't have delete
permissions for)
4. Page_Load (with IsPostback == true)
5. gvProjects_RowCommand (with CommandName == "DeleteProject"
and CommandArgument == the same index as in step 2 -- THIS CAUSES
ERRORS!!)
The last event causes various errors:
If the last row was being deleted, then the index from step 2 doesn't
exist anymore.
If a row somewhere in the middle was being deleted, then 2 projects
are being deleted, because the index in step 5 points to the row
following the row in step 2.
I can send code if you need it, but for some reason if I include C#
code in these newsgroup posts, my post doesn't make it to the group.
Any help is greatly appreciated.
-- Hans
maybe someone from the group can give me some pointers.
I have a webform with a gridview control that has a ButtonField column
(button is an icon). When the icon is clicked, the OnRowCommand is
fired with CommandName "DeleteProject".
All this is working fine, except that, upon clicking the icon, the
order of events is as follows:
1. Page_Load (with IsPostback == true)
2. gvProjects_RowCommand (with CommandName == "DeleteProject"
and CommandArgument == the index of the row; this is where the project
actually gets deleted through a stored procedure)
3. gvProjects_RowDataBound (nothing special happens here -- only
the icon is hidden for projects that the user doesn't have delete
permissions for)
4. Page_Load (with IsPostback == true)
5. gvProjects_RowCommand (with CommandName == "DeleteProject"
and CommandArgument == the same index as in step 2 -- THIS CAUSES
ERRORS!!)
The last event causes various errors:
If the last row was being deleted, then the index from step 2 doesn't
exist anymore.
If a row somewhere in the middle was being deleted, then 2 projects
are being deleted, because the index in step 5 points to the row
following the row in step 2.
I can send code if you need it, but for some reason if I include C#
code in these newsgroup posts, my post doesn't make it to the group.
Any help is greatly appreciated.
-- Hans