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

Combobox column validation always return "Input is not in a correct format" when value is null

2 Answers 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 17 May 2011, 07:43 PM
Situation:

The entity ppl_language has a few properties.  One of them would be the defLanguage, (represents another entity called defLanguage, not nullable).  The other is idLanguage which is the foreign key.  The grid is bound to ppl_languages, which is a ObservableCollection of ppl_language.

The items source of the combobox column is set in the data loaded event - it is binding to a ObservableCollection of DefLanguage

<telerik:RadGridView ItemsSource="{Binding ppl_languages}" Grid.Row="12" Grid.ColumnSpan="2" CanUserInsertRows="True" CanUserDeleteRows="true" ShowInsertRow="True"
                                                 AutoGenerateColumns="False" ShowGroupPanel="False" ShowGroupFooters="False" DataLoaded="gdvLanguage_DataLoaded" telerik:StyleManager.Theme="Windows7" >
                              <telerik:RadGridView.Columns>
                                  <telerik:GridViewComboBoxColumn Header="Language" DisplayMemberPath="desc1" SelectedValueMemberPath="idLanguage" DataMemberBinding="{Binding idLanguage}" />
                              </telerik:RadGridView.Columns>
                          </telerik:RadGridView>

The issue is since ppl_language. is not nullable, some item must be selected in the combobox.  However, when the combobox is empty it will only return the error message "input in not in a correct format".

Metadata for ppl_language

[Include]
            [Display(Name = "Language", Description = "Language")]
            [Association("ppl_language_defLanguage", "idLanguage ", "idLanguage ", IsForeignKey = true)]
            public defLanguage defLanguage { get; set; }
 
            [CustomValidation(typeof(PplLanguageValidator), "ValidateHasLanguage")]
            public int idLanguage { get; set; }

The custom validator should return the proper error message, but I put a break point in the custom validator and the code is only run AFTER I select something in the combobox - when nothing is selected the validator is not used at all and just return the incorrect format error.

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 18 May 2011, 02:35 PM
Hello Edward,

Basically, this would be the expected behavior since the custom validation will be performed after editing is performed and that validation will be on row-level. In the case of GridViewComboBoxColumn, selecting an item from the combo box is the editing on its nature, the custom validator will not be activated.
   

Best wishes,
Maya
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
Edward
Top achievements
Rank 1
answered on 18 May 2011, 02:56 PM
I kind of get around that by using CellEditTemplate and put a combobox there.  Then I will bind the ItemsSource and SelectedItem property in the loaded event.  It is not perfect but this is better than the "incorrect format" which does not really make sense.
Tags
GridView
Asked by
Edward
Top achievements
Rank 1
Answers by
Maya
Telerik team
Edward
Top achievements
Rank 1
Share this question
or