DynamicDataExtensions.ConvertEditedValue Method

Definition

Returns the value provided by a user for a control that is being validated.

C#
public static object ConvertEditedValue(this System.Web.DynamicData.IFieldFormattingOptions formattingOptions, string value);

Parameters

formattingOptions
IFieldFormattingOptions

The formatting options object, as defined by the IFieldFormattingOptions object.

value
String

The input value to be converted.

Returns

null if value is null or an empty string and the ConvertEmptyStringToNull property of formattingOptions is true; null if value is not null or an empty string and matches the NullDisplayText property of formattingOptions; otherwise, the unchanged value of value.

Examples

The following example shows how to use the ConvertEditedValue method. The example gets user input from a field template that is configured to accept date-time data. In the DynamicData\FieldTemplates\DateTime_Edit.ascx.cs or DynamicData\FieldTemplates\DateTime_Edit.ascx.vb file, the method converts empty strings to null.

C#
protected override void ExtractValues(IOrderedDictionary dictionary) {
    dictionary[Column.Name] = ConvertEditedValue(TextBox1.Text.Trim());
    // dictionary[Column.Name] = ConvertEditedValue(TextBox1.Text);
}

Remarks

For information about formatting options, see the IFieldFormattingOptions type overview.

Applies to

Product Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1