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

getting values before ending edit

3 Answers 10 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 22 Dec 2017, 05:36 AM

Hi,

I want to do a validation of the values entered before ending the edit (i.e. if nothing was entered in 1 column or an item wasn't selected from a combobox then show a message and cancel the edit).

Been trawling the forums and can't find the right advice...

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 22 Dec 2017, 10:54 AM
Hello Roger,

You can use the CellValidating event. For example:
private void RadGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
{
    if (e.Value == null)
    {
        e.Cancel = true;
        RadMessageBox.Show("Please enter value");
    }
}
 
I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Roger
Top achievements
Rank 1
answered on 02 Jan 2018, 03:17 AM

Hi Dimitar,

unfortunately there are issues with this method as there are conflicts between the columns (I have 3) when editing and moving off the column.

This table is included in a larger information collecting form.

I think it would be better to have a separate procedure to check the columns before saving the whole form and then throw a message box if any remain empty.

Thanks anyway.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Jan 2018, 10:46 AM
Hello, Roger, 

Thank you for writing back. 

In the CellValidatingEventArgs you have access to the column. Hence, you can check not only the value but the column as well. Here is a sample code snippet:
private void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
{
    if (this.radGridView1.IsInEditMode && e.Column.Name == "your column name" && e.Value == null)
    {
        e.Cancel = true;
        RadMessageBox.Show("Please enter value");
    }
}

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Roger
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Roger
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or