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

Validating Data on a Property Level can't catch the error

8 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jagan k
Top achievements
Rank 1
Jagan k asked on 06 Oct 2010, 12:10 PM
I have created RadGridview to check the Validating Data on a Property Level. When i run the code and give invalid value, exception is thrown but it wouldn't been caught by the RadGridView. I am Using
WPF 4.0    Version 2010.2 924

Here is the Code

<Window x:Class="WpfApplication1.Window1"
        Title="Window1" Height="300" Width="565" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Loaded="Window_Loaded">
    <Grid>
        <telerik:RadGridView Name="radGridView1" AddingNewDataItem="radGridView1_AddingNewDataItem" ShowInsertRow="True">
        </telerik:RadGridView>
    </Grid>
</Window>

using System;
using System.Windows;
using System.Collections.ObjectModel;
 
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
 
        public ObservableCollection<Employee> GetEmployees()
        {
            ObservableCollection<Employee> employees = new ObservableCollection<Employee>();
            return employees;
        }
 
        private void radGridView1_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            e.NewObject = new Employee();
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.radGridView1.ItemsSource = this.GetEmployees();
        }
 
    }
 
    public class Employee
    {
        string _FirstName;
 
        public string FirstName
        {
            get { return _FirstName; }
            set
            {
                if (value.Length > 5)
                {
                    throw new Exception("Firstname must be less than 6");
                }
                 _FirstName = value;
            }
        }
         
     }
}

check the attachment for error screen shot.

8 Answers, 1 is accepted

Sort by
0
Jagan k
Top achievements
Rank 1
answered on 06 Oct 2010, 12:12 PM
i am using windows xp sp3 and Visual Studio 2010
0
Veselin Vasilev
Telerik team
answered on 06 Oct 2010, 03:59 PM
Hi Jagan k,

I followed the steps described here and everything worked as expected. Please try setting the name of a club to any string which length is less than 3 in the attached sample project.

Greetings,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan k
Top achievements
Rank 1
answered on 07 Oct 2010, 08:56 AM
hi,

i have checked your project file and i think the exception is caught by "clubsGrid_CellValidating" event.
when i disable the code of "clubsGrid_CellValidating" event and try the invalid value in the name column, exception is not caught by grid.
I need clarification for property level and not for cell level.
i have check your help file that says property level validation is possible and can be displayed in the grid.
Path in the help file

Controls > RadGridView > Managing Data > Validation > Validating Data on a Property Level
0
Veselin Vasilev
Telerik team
answered on 12 Oct 2010, 04:40 PM
Hi Jagan k,

So, when you comment the code in the CellValidating event the validation is performed on data (property) level only. You will see that the exception is thrown in the setter of the Name property and the cell is in invalid state. What exactly do you expect to happen?

Kind regards,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan k
Top achievements
Rank 1
answered on 15 Oct 2010, 07:17 AM
hi,

   thanks for the reply. as per my view the exception has to be caught by the RadGridView and error message should be displayed in the RadGridView and not by the setter of the Name property. If the mentioned behavior by you is normal then what's the need for Property Level Validation.
0
Accepted
Veselin Vasilev
Telerik team
answered on 15 Oct 2010, 08:50 AM
Hello Jagan k,

Actually the RadGridView for WPF will display only a tooltip with the exception message in this case. We cannot show the normal error message in WPF (in Silverlight this is possible).
You need to have the latest version (the Q3 Beta scheduled for later today or Monday) or the Latest Internal Build scheduled for later today.


Best wishes,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rajesh
Top achievements
Rank 1
answered on 05 Jun 2012, 09:04 AM
Hi Veselin Vasilev ,
please let me how i can fix that issue in silver light.

please reply me as soon as you can.
i'm using silverlight 5 and Q2 version

Thanks in advance
Regards,
Rajesh KS.
0
Rajesh
Top achievements
Rank 1
answered on 05 Jun 2012, 12:25 PM
Hi Veselin Vasilev ,
please let me how i can fix that issue in silver light.

please reply me as soon as you can.
i'm using silverlight 5 and Q2 version and please check my attached sample and let me know how to fix the issue(on entering student id as less than 50).

Thanks in advance
Regards,
Rajesh KS.
Tags
GridView
Asked by
Jagan k
Top achievements
Rank 1
Answers by
Jagan k
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Rajesh
Top achievements
Rank 1
Share this question
or