Binding data while Itemsource is List<object>

I binding selectedItem in SFPicker with list of model contain property has type of meny typedata (int,string). But it not working, throw error "System.ArgumentException: Specified cast is not valid.Couldn't store <Models.ModelItemCombobox> in Approve_Status Column.  Expected type is Int32".

My model :
public class ModelItemCombobox
    {
        private object key;
        private object value;
        //private List<ModelItemCombobox> itemsSource;

        public object Key { get => key; set { this.key = value; } }
        public object Value { get => value; set => this.value = value; }

        public ModelItemCombobox()
        {
        }

        public ModelItemCombobox(object key, object value)
        {
            Key = key;
            Value = value;
        } 
    }

My binding :
SetBinding(SfPicker.SelectedItemProperty, "Dr[" + co.ColumnName + "]", BindingMode.TwoWay);
whith Dr is datarow

ItemSource has type :
Approve_Status   Description
0                     Draft
1                     Submited
2                     Approved
3                     Rejected
4                     Canceled
5                     Submitted to cancel register

Help me !

3 Replies

AS Anandraj Selvam Syncfusion Team March 26, 2020 05:22 PM UTC

Hi Son Hoang,   
   
Thanks for the update.  
   
Currently we are validating the reported issue and we will update you with more details on March 30, 2020.   
   
We appreciate your patience until then.  
   
Regards,   
Anand Raj S. 



SH Son Hoang March 27, 2020 12:49 AM UTC


Thanks you so much Anandraj Selvam, I will wait!


AS Anandraj Selvam Syncfusion Team March 27, 2020 11:37 AM UTC

Hi Son Hoang, 
  
Thanks for your update. 
  
We have validated the reported query and we suggest you to set the selected item based on the item collection to resolve the reported issue as like below code snippet: 
  
Code Snippet: 
  
var item= new ModelItemCombobox() { Key = 1, Value = "Submited" }; 
 
// In this, you can get the item from the items collection based on your column name and set item to selected item. 
 
viewModel.SelectedItems = viewModel.Items.Where(p => p.Value == item.Value).First(); 
picker.SetBinding(SfPicker.SelectedItemProperty,"SelectedItems",BindingMode.TwoWay); 
 
 
  
We have created sample for this and please find the sample from below link 
  
  
Screenshot: 
  
  
 
  
Please revert us for further investigation. 
  
Regards, 
Anand Raj S. 


Loader.
Up arrow icon