SqlDataSource.OldValuesParameterFormatString SqlDataSource.OldValuesParameterFormatString SqlDataSource.OldValuesParameterFormatString SqlDataSource.OldValuesParameterFormatString Property

定义

获取或设置一个格式字符串,该字符串应用于传递给 Delete()Update() 方法的所有参数的名称。Gets or sets a format string to apply to the names of any parameters that are passed to the Delete() or Update() method.

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

属性值

一个表示格式的字符串,该格式字符串应用于传递给 Delete()Update() 方法的所有 oldValues 参数的名称。A string that represents a format string applied to the names of any oldValues parameters passed to the Delete() or Update() methods. 默认值为“{0}”。The default is "{0}".

注解

格式字符串仅应用于主键 (如关联的数据绑定控件的DataKeyNames属性标识的主键), 或者应用于删除和更新方案中的ConflictDetection属性设置为OldValuesParameterFormatString CompareAllValues值和一组oldValues传递给相应的数据方法。The OldValuesParameterFormatString format string is applied only to primary keys, such as those that are identified by the DataKeyNames property of the associated data-bound control, or in delete and update scenarios where the ConflictDetection property is set to the CompareAllValues value and a set of oldValues are passed to the corresponding data method. 在这种情况下, 格式字符串将应用于oldValues集合中的每个参数名称。In this case, the format string is applied to each parameter name in the oldValues collection.

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

  • 区分更新中的旧值和新值。To differentiate between old and new values in updates. 如果将CompareAllValues属性设置为值, 则会将原始UpdateParameters值和新值的参数添加到集合中。 ConflictDetectionWhen 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.

适用于

另请参阅