DetailsView.InsertItem(Boolean) 方法

定义

将当前记录插入到数据源中。Inserts the current record in the data source.

public:
 virtual void InsertItem(bool causesValidation);
public virtual void InsertItem (bool causesValidation);
abstract member InsertItem : bool -> unit
override this.InsertItem : bool -> unit
Public Overridable Sub InsertItem (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 insert mode.

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

注解

当控件处于插入模式时, InsertItem使用方法以编程方式将当前记录插入到数据源中。 DetailsViewWhen the DetailsView control is in insert mode, use the InsertItem method to programmatically insert the current record in the data source. 如果需要从DetailsView控件之外插入当前记录 (例如, 来自页面上的不同控件), 通常会使用此方法。This method is commonly used when you need to insert 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 insert mode when this method is called; otherwise, an HttpException exception is thrown.

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

适用于

另请参阅