DataControlField.ViewState 屬性


取得狀態資訊的字典,允許您在相同頁面的多個要求之間,儲存和還原 DataControlField 物件的檢視狀態。Gets a dictionary of state information that allows you to save and restore the view state of a DataControlField object across multiple requests for the same page.

 property System::Web::UI::StateBag ^ ViewState { System::Web::UI::StateBag ^ get(); };
protected System.Web.UI.StateBag ViewState { get; }
member this.ViewState : System.Web.UI.StateBag
Protected ReadOnly Property ViewState As StateBag



StateBag 的執行個體,包含 DataControlField 檢視狀態資訊。An instance of StateBag that contains the DataControlField view-state information.


資料控制欄位的檢視狀態為其所有屬性值的累積。A data control field's view state is the accumulation of all its property values. 若要在 HTTP 要求之間保留這些值,ASP.NET server 控制項會使用這個屬性(這是類別的實例 StateBag )來儲存屬性值。To preserve these values across HTTP requests, ASP.NET server controls use this property, which is an instance of the StateBag class, to store the property values. 然後,這些值會在處理後續要求時,以變數形式傳遞至 HTML 隱藏的輸入元素。The values are then passed as a variable to an HTML hidden input element when subsequent requests are processed. 如需儲存伺服器控制項檢視狀態的詳細資訊,請參閱 ASP.NET 檢視狀態總覽For more information about saving server control view state, see ASP.NET View State Overview.

預設會為所有伺服器控制項啟用檢視狀態,但在某些情況下,您會想要停用它。View state is enabled for all server controls by default, but there are circumstances when you will want to disable it. 如需詳細資訊,請參閱 ASP.NET 效能總覽For more information, see ASP.NET Performance Overview.

如需有關字典以及如何使用它們的詳細資訊,請參閱 集合和資料結構For more information about dictionaries and how to use them, see Collections and Data Structures.