Link to home
Start Free TrialLog in
Avatar of Mr_Shaw
Mr_Shaw

asked on

gridview cancel

The custom gridview buttons let a user edit/update/delete/cancel etc.....

Is it possible to cancel the edit through a indepent button.
Avatar of David Robitaille
David Robitaille
Flag of Canada image

yes
set  CommandName="cancel"  and CausesValidation="False"
Avatar of Mr_Shaw
Mr_Shaw

ASKER

Do you mean

 <asp:Button ID="cancel_record_button" runat="server" CausesValidation="False"
                        CommandName="cancel" onclick="cancel_record_button_Click"
                        Text="Cancel" Visible="False" Width="78px" />
yes, but onclick="cancel_record_button_Click" is necesarry only if you do stuff in the cancel_record_button_Click. even. the  CommandName="cancel" should do the job.
There is also a event in the gridview "RowCancelingEdit" that will be run on cancel command event so you could put you code here if you want. thare is The row RowCommand that sould be raise on any command.
 CausesValidation="False" part allow post back event if there is some errors in a validator.
 
you could alos set the gridview.EditIndex = -1 in the cancel_record_button_Click event.
that will do the same job has the CommandName="cancel".
Avatar of Mr_Shaw

ASKER

I have tried using CommandName="cancel" but nothing happens
where did you put the button?
does the RowCommand event raised?
did you set CausesValidation="False"  ?
Avatar of Mr_Shaw

ASKER

No the RowCommand is not raised
the row command should be rised.
what do you mead by independant button?
if you are speaking of a button that is outside of the gridview then :
  1. remove all we talked about
  2. <asp:Button ID="cancel_record_button" runat="server" CausesValidation="False"
                            onclick="cancel_record_button_Click"
                            Text="Cancel" Visible="False" Width="78px" />
  3. in the cancel_record_button_Click event, set the gridview.EditIndex = -1
i dont know why you put Visible="False", did you toggle visibility in your code?
Avatar of Mr_Shaw

ASKER

you are right that this is a button outside of the gridview.

This button only become visible when the user clicks the edit button inside the gridview...It is a long story, but in short this is how my interface needs to be!

Anyway, i tried putting gridview.EditIndex = -1  inside my cancel_record_button_Click  but nothing happens. The gridview remains in the editing state.
ASKER CERTIFIED SOLUTION
Avatar of David Robitaille
David Robitaille
Flag of Canada image

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 Mr_Shaw

ASKER

it is all crack..

I had to rebind the data.
Thanks for the grade and i`m glad i could help!