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.
Mr_ShawAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David RobitailleAnalyst ProgrammerCommented:
yes
set  CommandName="cancel"  and CausesValidation="False"
0
Mr_ShawAuthor Commented:
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" />
0
David RobitailleAnalyst ProgrammerCommented:
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.
 
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

David RobitailleAnalyst ProgrammerCommented:
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".
0
Mr_ShawAuthor Commented:
I have tried using CommandName="cancel" but nothing happens
0
David RobitailleAnalyst ProgrammerCommented:
where did you put the button?
does the RowCommand event raised?
did you set CausesValidation="False"  ?
0
Mr_ShawAuthor Commented:
No the RowCommand is not raised
0
David RobitailleAnalyst ProgrammerCommented:
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?
0
Mr_ShawAuthor Commented:
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.
0
David RobitailleAnalyst ProgrammerCommented:
sorry, i forgot to say you have to call gridview.databind() to "refresh" the gridview after setting gridview.EditIndex = -1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mr_ShawAuthor Commented:
it is all crack..

I had to rebind the data.
0
David RobitailleAnalyst ProgrammerCommented:
Thanks for the grade and i`m glad i could help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.