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

How can I set data into the editors?

Hi,

I was wondering how I can set data into the editors when the from is not autogenerated.
And also how to perfom the validation.

Here is a example how I build the xaml.

With kind regards,

Vedad 

    <dataForm:SfDataForm x:Name="dataForm"
LabelPosition="Top"
ContainerType="Filled"
LayoutOptions="TextInputLayout"
AutoGenerateItems="False"
                         DataObject="{Binding Opdracht}">
<dataForm:SfDataForm.Items>
<dataForm:DataFormTextItem Name="Name" Editor="Text"/>
<dataForm:DataFormTextItem Name="Password" Editor="Password"/>
<dataForm:DataFormMaskedEditTextItem Name="Phone" Editor="MaskedEditText"/>
<dataForm:DataFormTextItem Name="Address" Editor="MultilineText"/>
<dataForm:DataFormDateItem Name="BirthTime" Editor="Date"/>
</dataForm:SfDataForm.Items>
</dataForm:SfDataForm>



1 Reply

KA Karthikraja Arumugam Syncfusion Team September 5, 2019 12:05 PM UTC

 
Thank you for contacting Syncfusion support. 
 
Query 1: Regarding validation while AutoGeneration set to false 
As per SfDataForm implementation, if we set AutoGeneration to false, DataFormItems will generate from XAML page but it will capture the details of curresponding property from the data model. So if you set validation attributes to the property then validation will perform as default 
 
Please refer the following code example for the same, 
 
[C#] 
[Required(AllowEmptyStrings = false, ErrorMessage = "Name should not be empty")] 
 public String Name { get; set; } 
 
 [StringLength(16,MinimumLength =8 , ErrorMessage = "Password should have 8-16 characters")] 
  public String Password { get; set; } 
 
 
Kindly refer our UG documentation to know more about validation in DataForm, 
 
Query 2: Regarding editors with values on initial loading while AutoGeneration set to false 
As we have mentioned, DataFormItem will generate with respective property information so if you set value for the property DatForm editors will have the value on initial loading. 
 
Please refer the following code example for the same, 
 
[C#]      
public ContactInfo() 
{ 
            contactDetails = new Contacts(); 
            contactDetails.Name = "Jhon"; 
 } 
 
We have prepared a sample based on your requirement, please find the sample by the following link. 

Sample link:
DataForm 
 
In the sample, as per your requirement we have set validation attributes for validation and set values for properties on initial loading. 
 
We hope this helps. Please let us know, if you need any further assistance. 
 
Regards,
Karthik Raja A
 


Loader.
Live Chat Icon For mobile
Up arrow icon