DynamicDataExtensions.ConvertEditedValue(IFieldFormattingOptions, String) DynamicDataExtensions.ConvertEditedValue(IFieldFormattingOptions, String) DynamicDataExtensions.ConvertEditedValue(IFieldFormattingOptions, String) DynamicDataExtensions.ConvertEditedValue(IFieldFormattingOptions, String) Method

定義

針對已驗證的控制項傳回使用者提供的值。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

參數

formattingOptions
IFieldFormattingOptions IFieldFormattingOptions IFieldFormattingOptions IFieldFormattingOptions

格式化選項物件,如 IFieldFormattingOptions 物件所定義。The formatting options object, as defined by the IFieldFormattingOptions object.

value
String String String String

要轉換的輸入值。The input value to be converted.

傳回

如果 valuenull 或空字串且 formattingOptionsConvertEmptyStringToNull 屬性是 true,則為 null;如果 value 不是 null 或空字串且與 formattingOptionsNullDisplayText 屬性相符,則為 null;否則為 value 未變更的值。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.

範例

下列範例會示範如何使用 ConvertEditedValue 方法。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. 在 DynamicData\FieldTemplates\DateTime_Edit.ascx.cs 或 DynamicData\FieldTemplates\DateTime_Edit.ascx.vb 檔案中,方法會將空字串轉換null成。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);
} 

備註

如需格式化選項的詳細資訊, IFieldFormattingOptions請參閱類型總覽。For information about formatting options, see the IFieldFormattingOptions type overview.

適用於