Share via


DataSourceView.CanInsert 屬性

定義

取得值,指出與目前 DataSourceView 物件關聯的 DataSourceControl 物件是否支援 ExecuteInsert(IDictionary) 作業。

public:
 virtual property bool CanInsert { bool get(); };
public virtual bool CanInsert { get; }
member this.CanInsert : bool
Public Overridable ReadOnly Property CanInsert As Boolean

屬性值

如果支援該作業則為 true,否則為 false。 基底類別實作會傳回 false

範例

下列程式碼範例示範如何在擴充 DataSourceView 類別的類別中覆寫 CanInsert 屬性和 ExecuteInsert 方法。 此程式碼範例是提供給 類別之較大範例的 DataSourceView 一部分。

// The CsvDataSourceView does not currently
// permit insertion of a new record. You can
// modify or extend this sample to do so.
public override bool CanInsert {
    get {
        return false;
    }
}
protected override int ExecuteInsert(IDictionary values)
{
    throw new NotSupportedException();
}
' The CsvDataSourceView does not currently
' permit insertion of a new record. You can
' modify or extend this sample to do so.
Public Overrides ReadOnly Property CanInsert() As Boolean
   Get
      Return False
   End Get
End Property

Protected Overrides Function ExecuteInsert(values As IDictionary) As Integer
   Throw New NotSupportedException()
End Function 'ExecuteInsert

備註

屬性 CanInsert 不僅反映資料來源控制項的功能,也反映目前是否適合執行作業。 例如,即使資料來源控制項支援 ExecuteInsert 作業,但如果未設定必要的插入命令或其他資料,屬性會傳 false 回 , CanInsert 因為插入作業會失敗。

適用於

另請參閱