This is a migrated thread and some comments may be shown as answers.

How to cancel an edit.

2 Answers 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose Simas
Top achievements
Rank 2
Jose Simas asked on 04 Mar 2011, 12:56 PM
Hi,

I have a grid with numeric data that can be edited by the user. If the user enters a non numeric value the edit should be cancelled and the cell value should revert to the original value (skipping validation). When the grid is bound to a DataTable I am able to do this using the CellValidating event as such:

private void OnManualSplitPointsValidating(object sender, GridViewCellValidatingEventArgs e)
        {
            if (Helper.IsNumeric(e.NewValue) == false)
            {
                var grid = (RadGridView) sender;
                grid.CancelEdit();
            }
        }

But when I apply this same code to a CSLA collection the line grid.CancelEdit() causes a row deletion. This may be a problem with the CSLA list but I wanted to check if there is a different way of reverting to the previous value (or if indeed this is supported at all).

I am using the latest Beta and .NET 4.0.

Cheers,
Jose

2 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 06 Mar 2011, 01:08 AM
Hi Jose Simas,

 You can just set the cell as invalid. That way the user won't be able to complete the edit operation until the cell contains a valid value and the underlying data for the cell won't be modified.

Kind regards,
Yavor Georgiev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Jose Simas
Top achievements
Rank 2
answered on 06 Mar 2011, 10:12 AM
Hi,

I could indeed but I am being asked to revert to the previous value. As I said, it works just fine when the grid is bound to a DataTable but unfortunately it causes side effects when I call CancelEdit if it is bound to a CSLA collection. I post this thread to see if there was an alternate way of doing this.

Cheers,
Jose
Tags
GridView
Asked by
Jose Simas
Top achievements
Rank 2
Answers by
Yavor Georgiev
Telerik team
Jose Simas
Top achievements
Rank 2
Share this question
or