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

Validation on RadGridView cell

1 Answer 150 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ranjit
Top achievements
Rank 1
Ranjit asked on 08 Mar 2012, 06:22 PM
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.

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 12 Mar 2012, 09:54 AM
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 >>
Tags
GridView
Asked by
Ranjit
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or