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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I set data into the editors?

Thread ID:

Created:

Updated:

Platform:

Replies:

147222 Sep 4,2019 09:57 AM UTC Sep 5,2019 12:05 PM UTC Xamarin.Forms 1
loading
Tags: SfDataForm
Vedad
Asked On September 4, 2019 09:57 AM UTC

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>



Karthikraja Arumugam [Syncfusion]
Replied On 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
 


CONFIRMATION

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