Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / August 2003

Tip: Looking for answers? Try searching our database.

cancel saving data in datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Calvin - 26 Aug 2003 11:22 GMT
My datagrid cells are all editable textbox and attached onTextChanged event
so that every changes will be saved in the datatable on next postback. My
problem is if the cancel button is clicked instead of save button, i don't
want to do any validation and saving data to datatable but only just quit. I
can't do that now becuase the onTextChanged event runs before cancel button
click event. So, is there a way to solve it?
Thanks
Jim Nugent - 27 Aug 2003 02:25 GMT
I may be missing something but why not:
1. Disable validation for your cancel button (set the property "Causes
Validation" to false).
2. Save your data in the saveButton  Click handler, rather than TextChanged.
That way if cancel is pressed, validation won't occur and changes won't be
saved. You can redirect to another page or whatever.
Signature

Jim
"Remember, an amateur built the Ark; professionals built the Titanic."

> My datagrid cells are all editable textbox and attached onTextChanged event
> so that every changes will be saved in the datatable on next postback. My
[quoted text clipped - 3 lines]
> click event. So, is there a way to solve it?
> Thanks
Calvin - 27 Aug 2003 03:43 GMT
My datagrid is editable which means all cells in all rows are textbox
instead of label. So, at any time, the data can be changed. When the field
is updated, OnTextChanged event fires and the data is saved to datatable
first. So, even I set the cancel button causes validation to false, the
OnTextChanged event still fires and so error occurs since the datatype
mis-matched from the datatable. I must have the OnTextChanged event,
otherwise all changed event may be lost on next postback.

> I may be missing something but why not:
> 1. Disable validation for your cancel button (set the property "Causes
[quoted text clipped - 12 lines]
> > click event. So, is there a way to solve it?
> > Thanks
Jim Nugent - 27 Aug 2003 14:16 GMT
There are a couple of ways around this I think.
The  first one I KNOW works because we use it:
1. Have an edit linkbutton in the first column of your grid. In the
linkbutton command handler, grab the data and put up a different page with
that data in a text box and allow it to be edited. It's more elegant IMHO
anyway and allows you to have textboxes and dropdown lists, etc. if
appopriate for your grid columns. Have save and cancel available. Save (on
the "edit" page) updates that row of the table; cancel bails out without
firing the validator.

2. Let the grid edits modify your DataSet object (in memory), and  save out
your DataSet to to the DB table at one in the save handler. Each row in your
ds has a RowChanged (or something like that) property so you can even get
efficient and only update the ones that need it.
Signature

Jim
"Remember, an amateur built the Ark; professionals built the Titanic."

> My datagrid is editable which means all cells in all rows are textbox
> instead of label. So, at any time, the data can be changed. When the field
[quoted text clipped - 24 lines]
> > > click event. So, is there a way to solve it?
> > > Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.