DetailsView.UpdateItem(Boolean) 方法

定义

更新数据源中的当前记录。Updates the current record in the data source.

public:
 virtual void UpdateItem(bool causesValidation);
public virtual void UpdateItem (bool causesValidation);
abstract member UpdateItem : bool -> unit
override this.UpdateItem : bool -> unit
Public Overridable Sub UpdateItem (causesValidation As Boolean)

参数

causesValidation
Boolean

true 表示调用该方法时执行页验证;否则为 falsetrue to perform page validation when the method is called; otherwise, false.

异常

此方法在 DetailsView 控件不处于编辑模式时调用。This method is called when the DetailsView control is not in edit mode.

-or- DataSourceView 控件关联的 DetailsViewnullThe DataSourceView associated with the DetailsView control is null.

注解

当控件处于编辑模式时, UpdateItem使用方法以编程方式更新数据源中的当前记录。 DetailsViewWhen the DetailsView control is in edit mode, use the UpdateItem method to programmatically update the current record in the data source. 如果需要从DetailsView控件之外 (如页面上的不同控件) 更新当前记录, 通常会使用此方法。This method is commonly used when you need to update the current record from outside of the DetailsView control, such as from a different control on the page.

备注

调用DetailsView此方法时, 控件必须处于编辑模式; 否则HttpException , 将引发异常。The DetailsView control must be in edit mode when this method is called; otherwise, an HttpException exception is thrown.

若要指定在更新操作之前是否执行页验证, 请使用causesValidation参数。To specify whether page validation is performed before the update operation, use the causesValidation parameter. 调用此方法还会引发ItemUpdatedItemUpdating事件。Calling this method also raises the ItemUpdated and ItemUpdating events.

适用于

另请参阅