DynamicDataExtensions.ConvertEditedValue Method (IFieldFormattingOptions, String)


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

Namespace:   System.Web.DynamicData
Assembly:  System.Web.DynamicData (in System.Web.DynamicData.dll)

static member ConvertEditedValue : 
        formattingOptions:IFieldFormattingOptions *
        value:string -> Object


Type: System.Web.DynamicData.IFieldFormattingOptions

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

Type: System.String

The input value to be converted.

Return Value

Type: System.Object

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.

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

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.

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

.NET Framework
Available since 3.5
Return to top