Breyta

Deila með


DynamicDataExtensions.ConvertEditedValue Method

Definition

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

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ ConvertEditedValue(System::Web::DynamicData::IFieldFormattingOptions ^ formattingOptions, System::String ^ value);
public static object ConvertEditedValue (this System.Web.DynamicData.IFieldFormattingOptions formattingOptions, string value);
static member ConvertEditedValue : System.Web.DynamicData.IFieldFormattingOptions * string -> obj
<Extension()>
Public Function ConvertEditedValue (formattingOptions As IFieldFormattingOptions, value As String) As Object

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.

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