ObjectDataSourceView.OldValuesParameterFormatString 属性

定义

获取或设置一个格式字符串,该字符串应用于传递给 DeleteUpdate 方法的原始值的参数名称。Gets or sets a format string to apply to the names of the parameters for original values that are passed to the Delete or Update methods.

public:
 property System::String ^ OldValuesParameterFormatString { System::String ^ get(); void set(System::String ^ value); };
public string OldValuesParameterFormatString { get; set; }
member this.OldValuesParameterFormatString : string with get, set
Public Property OldValuesParameterFormatString As String

属性值

String

一个字符串,表示应用于传递给 DeleteUpdate 方法的任何 oldValues 的名称的格式字符串。A string that represents a format string applied to the names of any oldValues passed to the Delete or Update method. 默认值为 " {0} ",这意味着参数名称只是字段名称。The default is "{0}", which means the parameter name is simply the field name.

注解

OldValuesParameterFormatString格式字符串仅应用于主键,如使用 DataKeyNames 数据绑定控件的属性标识的属性,或在删除和更新方案中标识的属性,其中 ConflictDetection 属性设置为 CompareAllValues 值以及传递给相应数据方法的原始值集。The OldValuesParameterFormatString format string is applied to primary keys only, such as those that are identified with the DataKeyNames property of a data-bound control or in delete and update scenarios, where the ConflictDetection property is set to the CompareAllValues value and the set of original values that are passed to the corresponding data method.

下面是两种可能更改属性的常见方案 OldValuesParameterFormatStringTwo common scenarios where you might change the OldValuesParameterFormatString property are as follows:

  • 区分更新中的旧值和新值。To differentiate between old and new values in updates. 如果将 ConflictDetection 属性设置为 CompareAllValues 值,则会将原始值和新值的参数添加到集合中 UpdateParametersWhen the ConflictDetection property is set to the CompareAllValues value, parameters for both the original and new values are added to the UpdateParameters collection. 如果没有格式字符串,则将为每个数据字段创建两个具有相同名称的参数。Without the formatting string, two parameters with the same name would be created for each data field. 通过更改原始值参数的名称,可以将数据与原始数据源进行比较,以检测冲突并比较键值。By changing the name of the original value parameter, you can compare the data to the original data source to detect conflicts and compare key values.

  • 某些可视化设计器为原始值和键实现了特定的命名方案。Some visual designers implement a particular naming scheme for original values and keys.

的值 OldValuesParameterFormatString 存储在视图状态中。The value of the OldValuesParameterFormatString is stored in view state.

适用于

另请参阅