We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataFormDropDownItem default value

Thread ID:





144925 May 29,2019 05:49 AM UTC May 30,2019 02:13 PM UTC Xamarin.Forms 1
Tags: SfDataForm
Asked On May 29, 2019 05:49 AM UTC

I am adding a dropdown to the form in the behavior class. If I don't have  selected value in the dropdown when I am doing the validation of the form I get an error. 

How can I set the default value of the of the dropdownitem?

The code below is sample of the added dropdown but I need to select a value by default.

items00.Add(new DataFormDropDownItem() { Name = "IdClass", Editor = "DropDown",  LabelText = "Class:", ItemsSource = oListValue.GetSource("Class"), DisplayMemberPath = "Description", SelectedValuePath = "IdClass" });


Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 30, 2019 02:13 PM UTC

Hi Leon, 
Thank you contacting Syncfusion support. 
We have analyzed your query “How to set default value for DataFormDropDownItem?”, you can set any of value from ItemsCollection in DropDown item’s underlying property to display the selected item. Editor cell value will be converted and given value will be selected from ItemsSource. If you want to use complex class for DropDown then set value of SelectedValuePath. 
Code Snippet: 
private IList GetItemSource(string sourceName) 
  List<Address> details = new List<Address>(); 
  if (sourceName == "City") 
       details.Add(new Address() { City = "Chennai", PostalCode = 1 }); 
       details.Add(new Address() { City = "Paris", PostalCode = 2 }); 
       details.Add(new Address() { City = "Vatican", PostalCode = 3 }); 
  return details; 
public class ContactsInfo 
     public string City { getset; } = "1"; 
We have prepared sample for the same, 
Sample : DataForm 
We hope that this helps you, kindly revert us if you have any concern. 
Subburaj Pandian V


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon