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);
} 

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5 SP1

Community Additions

ADD
Show:
© 2015 Microsoft