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

Cell Validation in GridView

2 Answers 191 Views
GridView
This is a migrated thread and some comments may be shown as answers.
shortie
Top achievements
Rank 2
shortie asked on 29 Jul 2009, 03:00 AM
Hello,

We used to use Validating event to do cell validation in the versions before Q2. This event will get fired when a user types in a cell and then moves the input focus to another cell in the same row, to another cell in different rows or to other controls in the form.

In Q2, it seems that this event won't get fired as the previous versions do. How can we achieve cell validation that our customers ask us to do in Q2?

Thanks in advance

BR/shortie

2 Answers, 1 is accepted

Sort by
0
Accepted
Boryana
Telerik team
answered on 29 Jul 2009, 04:47 PM
Hi ChunChang,

Thank you for contacting us.

The Validating event is triggered whenever the RadGridView loses focus. In your case I believe that the most convenient event to handle is CellValidating. It fires each time a cell loses focus. Please, note that the cell should not necessarily have been in edit mode in order to fire the event. This implies that CellValidating is triggered when the user changes the selected cell, even if the RadGridView is ReadOnly.

However, if you would like to handle the cases only when the value of the cell is being changed, you can use the following approach:

private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) 
    if (this.radGridView1.IsInEditMode) 
    { 
        //Your code goes in here 
    } 

I hope this is helpful. If you encounter further issues, please, contact me back.

Best wishes,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
shortie
Top achievements
Rank 2
answered on 30 Jul 2009, 02:35 AM
Hi Boryana,

Thanks for your help. The CellValidating is the event we need. Does this event exist in the earlier versions? If it did, we must use the wrong event (Validating) in former versions. Anyway, you saved our life and our customers are happy now. Thanks again.

BR/shortie

Tags
GridView
Asked by
shortie
Top achievements
Rank 2
Answers by
Boryana
Telerik team
shortie
Top achievements
Rank 2
Share this question
or