DetailsView.OnPagePreLoad(Object, EventArgs) 方法

定义

在加载数据绑定控件之前设置该控件的初始化状态。Sets the initialized state of the data-bound control before the control is loaded.

protected:
 override void OnPagePreLoad(System::Object ^ sender, EventArgs ^ e);
protected override void OnPagePreLoad (object sender, EventArgs e);
override this.OnPagePreLoad : obj * EventArgs -> unit
Protected Overrides Sub OnPagePreLoad (sender As Object, e As EventArgs)

参数

sender
Object

引发事件的 PageThe Page that raised the event.

e
EventArgs

包含事件数据的 EventArgsAn EventArgs that contains the event data.

注解

OnPagePreLoad 方法用于控制在页面的生命周期内何时发生数据绑定。The OnPagePreLoad method is used to control when data binding occurs within the life cycle of the page. 它通过设置数据绑定控件的内部初始化状态来实现此功能。It does this by setting the internal initialized state of the data-bound control. 由于控件的已初始化状态是在页面生命周期的 PreLoad 阶段中设置的,因此只要在该阶段后更改控件的数据属性,就会调用 OnDataPropertyChanged 事件处理程序,以指示控件在呈现之前必须重新绑定到其数据。Because the control's initialized state is set during the PreLoad phase of the page's life cycle, the OnDataPropertyChanged event handler is called any time a data property of the control is changed after that phase, to signal that the control must re-bind to its data before rendering.

如果 HTTP 请求为回发但启用了视图状态,但数据绑定控件尚未绑定,则 DetailsView 类将重写 OnPagePreLoad 方法,以将 RequiresDataBinding 属性设置为 trueThe OnPagePreLoad method is overridden by the DetailsView class to set the RequiresDataBinding property to true in cases where the HTTP request is a postback and view state is enabled but the data-bound control has not yet been bound. 这种情况很常见,例如 WizardMultiView,控件在运行时更改了控件的可见性。This scenario is common with controls such as Wizard and MultiView, where the visibility of the control is changed at run time.

适用于

另请参阅