共用方式為


DataSourceView.CanUpdate 屬性

定義

會取得一個值,表示與目前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,因為更新操作將失敗。

適用於

另請參閱