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

DataFormDropDownItem default value

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" });


1 Reply

SP Subburaj Pandian Veluchamy Syncfusion Team May 30, 2019 09:13 AM

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

Live Chat Icon For mobile
Up arrow icon