DataSourceView.CanUpdate 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會取得一個值,表示與目前DataSourceControl物件相關聯的DataSourceView物件是否支援該ExecuteUpdate(IDictionary, IDictionary, IDictionary)操作。
public:
virtual property bool CanUpdate { bool get(); };
public virtual bool CanUpdate { get; }
member this.CanUpdate : bool
Public Overridable ReadOnly Property CanUpdate As Boolean
屬性值
true如果該操作被支援;否則,。 false 預設實作會傳回 false。
範例
以下程式碼範例示範如何在擴充DataSourceView類別中覆寫該CanUpdate屬性與ExecuteUpdate方法。 此程式碼範例是本類別更大範例 DataSourceView 的一部分。
// The CsvDataSourceView does not currently
// permit update operations. You can modify or
// extend this sample to do so.
public override bool CanUpdate {
get {
return false;
}
}
protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
{
throw new NotSupportedException();
}
' The CsvDataSourceView does not currently
' permit update operations. You can modify or
' extend this sample to do so.
Public Overrides ReadOnly Property CanUpdate() As Boolean
Get
Return False
End Get
End Property
Protected Overrides Function ExecuteUpdate(keys As IDictionary, _
values As IDictionary, _
oldValues As IDictionary) As Integer
Throw New NotSupportedException()
End Function 'ExecuteUpdate
End Class
備註
此 CanUpdate 屬性不僅反映資料來源控制的能力,也反映目前是否適合執行某操作。 例如,即使資料綁定控制項支援該 ExecuteUpdate 操作,若未設定 CanUpdate 所需的更新指令或其他資料,該屬性會回傳 false,因為更新操作將失敗。