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)

public static Object ConvertEditedValue(
	this IFieldFormattingOptions formattingOptions,
	string value
)

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

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


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


.NET Framework

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft