Validation on RadGridView cell

2 posts, 0 answers
  1. Ranjit
    Ranjit avatar
    12 posts
    Member since:
    Oct 2011

    Posted 08 Mar 2012 Link to this post

    Hello all,

    I'm running into some issues trying to trigger the validation in my RadGridView which is in a custom control in lightswitch.
    For the entity I am adding a property error (I've tried adding entity error as well with no luck) :

    partial void StateCode_Validate(EntityValidationResultsBuilder results)
            {
                if (String.IsNullOrEmpty(StateCode) || this.StateCode.Length > 2)
                {
                    results.AddPropertyError("State code must be two characters.");
                }
            }

    Now in the custom control, I have set all the validation flags but cannot get the grid to pickup on the validation errors.
    Is there something I am doing wrong here?

    <Grid x:Name="LayoutRoot" Background="White">
            <StackPanel Orientation="Vertical">
                <telerik1:RadGridView x:Name="BrokerSOVGrid"
                                    Width="1200"
                                    AutoGenerateColumns="False"
                                    ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                    ItemsSource="{Binding Screen.tblLocations, Mode=TwoWay,
                                        ValidatesOnDataErrors=True,
                                        NotifyOnValidationError=True}"
                                    ActionOnLostFocus="CommitEdit"
                                    ValidatesOnDataErrors="InViewMode">
                    <telerik1:RadGridView.Columns>
                        
                        <telerik1:GridViewDataColumn Header="StateCode" UniqueName="StateCode" 
                                                     DataMemberBinding="{Binding StateCode,
                                                        ValidatesOnDataErrors=True, 
                                                        NotifyOnValidationError=True, 
                                                        Mode=TwoWay, 
                                                        ValidatesOnNotifyDataErrors=True, 
                                                        ValidatesOnExceptions=True}" 
                                                     ValidatesOnDataErrors="InEditMode"
                                                     />
                        <telerik1:GridViewDataColumn UniqueName="NumBldgs" 
                                                     DataMemberBinding="{Binding NumBldgs, 
                                                        NotifyOnValidationError=True, 
                                                        ValidatesOnDataErrors=True, 
                                                        Mode=TwoWay, 
                                                        ValidatesOnNotifyDataErrors=True, 
                                                        ValidatesOnExceptions=True}" 
                                                     ValidatesOnDataErrors="InEditMode"
                                                     />
                    </telerik1:RadGridView.Columns>
                </telerik1:RadGridView>


    I've been back and forth trying to get this to work with no luck, could really use some backup.

    The validation will trigger when I try to enter a string into an integer field... but it's not picking up on the custom validation rules we have made.

  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 12 Mar 2012 Link to this post

    Hello,

    Unfortunately I cannot figure out what is going on with the provided information. Could you please send me a little bit more info about how do you validate your business object (via IDataErrorInfo or DataAnnotation attributes)?
    It will be very helpful if you send me a sample application which I can debug on my side in order to see what is going on.

    Regards,
    Nedyalko Nikolov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top