In my gridRowUpdating() event, I perform some client-side validation. If the validation doesn't pass, I cancel the update by calling e.set_cancel(true);
This works fine, except for this big caveat: the row will then revert back to its original values. This is bad because all the information that the user provided then goes away, and he has to start all over again!
Is there any way to cancel the Gridview's Update, without clearing out the data in the row?
Alex, I am in the exact same boat, except for me it is the ADD function.
Can you give more detail on exactly how you would write what you are suggesting to do?
/Tom
Do you mean you should use something like a timer event to re-populate the new row? I really dont like that.
Is there really no elegant way to do this? Maybe some event that we can hook into after the updaterow event. Or something we can override to prevent the row from clearing?
I would imagine this is pretty standard stuff, but after spending a day on finding a solution I'm really stuck on this.
If you have any other ideas, im very interested.
*edit: I'm aware this is an old thread, but it is exactly what i'm looking for..
If this is not the way to do row validation, how would you suggest to do it?
Unfortunately the grid assumes that the action for the row is canceled completely and returns old values for the whole row.
I can suggest to remember all of the cell values in the rowUpdating event handler and then write a helper function that will be executed on a timeout which would call set_value for each cell and set the new values on the row cells again.
*bump*
Any help on this guys?
Hi supervin,
That's exactly the same problem I'm facing! Here is what I did in UltraWebGrid.
In the past when I use UltraWebGrid, I don't call e.Cancel = True. I just let the UpdateRowBatch run and don't update the database. Doing thing will keep the old data on the cell.
But this will create another problem, since I didn't call e.Cancel, UltraWebGrid assumes the update is success. If user click the submit button again without any change, UpdateRowBatch will not fire. Therefore I added a status column to mark down the error row and use javascript to remove the mark to fake UltraWebGrid that it is edited by someone. It can cause UpdateRowBatch to be fired in the next postback.
The above workaround works fine in UltraWebGrid, but I'm not sure whether it can be used in WebDataGrid.
Can anyone provide a better solution to this problem?