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

Rad combobox Validation issue

0 Answers 112 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Shenbagaraj
Top achievements
Rank 1
Shenbagaraj asked on 27 Dec 2011, 12:38 PM
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............

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Shenbagaraj
Top achievements
Rank 1
Share this question
or