?
Solved

gridview cancel

Posted on 2008-11-10
12
Medium Priority
?
554 Views
Last Modified: 2013-12-17
The custom gridview buttons let a user edit/update/delete/cancel etc.....

Is it possible to cancel the edit through a indepent button.
0
Comment
Question by:Mr_Shaw
  • 7
  • 5
12 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22921440
yes
set  CommandName="cancel"  and CausesValidation="False"
0
 

Author Comment

by:Mr_Shaw
ID: 22921487
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
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22921547
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 18

Expert Comment

by:David Robitaille
ID: 22921574
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
 

Author Comment

by:Mr_Shaw
ID: 22922500
I have tried using CommandName="cancel" but nothing happens
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22922574
where did you put the button?
does the RowCommand event raised?
did you set CausesValidation="False"  ?
0
 

Author Comment

by:Mr_Shaw
ID: 22922675
No the RowCommand is not raised
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22922733
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
 

Author Comment

by:Mr_Shaw
ID: 22922960
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
 
LVL 18

Accepted Solution

by:
David Robitaille earned 2000 total points
ID: 22922997
sorry, i forgot to say you have to call gridview.databind() to "refresh" the gridview after setting gridview.EditIndex = -1
0
 

Author Comment

by:Mr_Shaw
ID: 22923081
it is all crack..

I had to rebind the data.
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22923228
Thanks for the grade and i`m glad i could help!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question