Set value at the runtime and set a default value on sfDataForm

Hi,

I have a field which is used sometimes, depending on user's selection. This field is defined as "AllowedEmptyStrings = False", so whenever this field is empty, the validation cannot be completed and we get an error. That's a good thing when we have an active field. But. When this field is not intended to be used (visible = false), what can we do with this empty field? I tried to define a default value in dataform_autogeneratingdataformitem as follows:

(e.DataFormItem as DataFormNumericItem).ItemManager.SetValue(dataForm.ItemManager.DataFormItems["fieldname"], "mytext")

but it did not work out... I tried a similar method in dataformgettingstarted_propertychanged with no luck

dataformItm_FieldName.ItemManager.SetValue(dataForm.ItemManager.DataFormItems["fieldname"], "mytext")

Thank you!

Nicolas


2 Replies

NI Nicolas October 20, 2017 04:48 PM UTC

ok resolved! Only missing one item!

dataformItm_FieldName.ItemManager.SetValue(dataformItm_FieldName, "mytext");

dataForm.UpdateEditor("myfield");

Thanks!

Nicolas




TV Thangapriya V Syncfusion Team October 23, 2017 06:57 AM UTC

Hi Nicolas, 
We are glad to know that your issue has been resolved. Please let us know if you need any other assistance.  
Regards, 
Thangapriya 


Loader.
Up arrow icon