Rad combobox Validation issue

1 posts, 0 answers
  1. Shenbagaraj
    Shenbagaraj avatar
    9 posts
    Member since:
    Dec 2011

    Posted 27 Dec 2011 Link to this post

    Im using RadCombobox the validation is firing correctly when i use Combobox but when i changed to radcombobox its not firing
    if i use combobox its working fine.. plz guys help me ASAP...

    here is my code it highlights and fires when its combo box

    <

    ComboBox Name="comboboxMagazine" MinWidth="140" MaxWidth="300" Grid.Row="1" Grid.Column="3" Height="20" DisplayMemberPath="MagazineName" SelectedValuePath="MagazineID" ItemsSource="{Binding MagazineData, Mode=OneWay,Converter={StaticResource AddEmptyItemConverter}}" SelectedValue="{Binding JobRequest.MagazineID, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnNotifyDataErrors=True, NotifyOnValidationError=True}"/ >

     when i changed to RADCOMBOBOX its not firing and not showing the validation in validation summary. 

    <telerik:RadComboBox Name="comboboxMagazine" MinWidth="140" MaxWidth="300" Grid.Row="1" Grid.Column="3" Height="20" DisplayMemberPath="MagazineName" SelectedValuePath="MagazineID" ItemsSource="{Binding MagazineData, Mode=OneWay,Converter={StaticResource AddEmptyItemConverter}}" SelectedValue="{Binding JobRequest.MagazineID, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnNotifyDataErrors=True, NotifyOnValidationError=True}" />

     
    my business validation class  called from context metadata as

     

    [CustomValidation(typeof(BusinessValidation), "EmptyComboBoxValidation")]

     

     

    public static ValidationResult EmptyComboBoxValidation(int id, ValidationContext validationContext) {

     int stringDifference = -1;
    switch (validationContext.MemberName) {
    case "RequestCodeID":{

     stringDifference = validationContext.MemberName.CompareTo( "RequestCodeID");  

    if (stringDifference == 0 && id == 0) {

     return new ValidationResult("Select a Job Request.", new[] { validationContext.MemberName });
    }

    break;  }}

    my AddEmptyItemConverter class

     

    public class AddEmptyItemConverter : IValueConverter 

     {

    public object Convert(dynamic value, Type targetType, object parameter, CultureInfo culture)

     { 

    if (value != null)

     if (value.GetType().IsGenericType)

    if (value.Count > 0)

     value.Insert(0,

     Activator.CreateInstance(value[0].GetType()));

     return value;

     }

      

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

     {

     return value;

     }

    }


    help me ASAP............

Back to Top