Export (0) Print
Expand All

DynamicDataExtensions.ConvertEditedValue Method

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)

'Declaration
<ExtensionAttribute> _
Public Shared Function ConvertEditedValue ( _
	formattingOptions As IFieldFormattingOptions, _
	value As String _
) As Object

Parameters

formattingOptions
Type: System.Web.DynamicData.IFieldFormattingOptions

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

value
Type: System.String

The input value to be converted.

Return Value

Type: System.Object
Nothing if value is Nothing or an empty string and the ConvertEmptyStringToNull property of formattingOptions is true; Nothing if value is not Nothing or an empty string and matches the NullDisplayText property of formattingOptions; otherwise, the unchanged value of value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IFieldFormattingOptions. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

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 Nothing.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1
Show:
© 2015 Microsoft