2009-08-11 46 views
2

问候,这是我们可以强制ObjectDataSource ...的唯一方法吗?


1)I假设的ObjectDataSource自动绑定到数据源只在第一次请求,但不能在回发(否则ObjectDataSource.Selecting事件将在回发也被触发,但它不是):

A)来强制的ObjectDataSource也绑定上回发那么唯一的办法是通过手动调用的DataBind()


2)假设DropDownList1具有的DataSourceID集到ObjectDataSource1,然后第一次加载页面时,ObjectDataSource1会自动调用DropDownList1.DataBind()(后页。 PreRender事件)并插入检索到的数据。


A)但是,如果我们还手动调用DropDownList1.DataBind()当第一次加载页面:

​​


威尔ObjectDataSource1莫名其妙地注意到DropDownList1。 DataBind()已被调用,因此不会自动调用DropDownList1.DataBind()


B)通常ObjectDataSource1.Selecting事件后Page.Prerender event.But烧什么,如果DropDownList1.DataBind()被称为内的Page_Load()

将在这种情况下,ObjectDataSource1.Selecting事件之前Page.PreRender解雇?


感谢名单

回答

3

请问在这种情况下ObjectDataSource1.Selecting事件Page.PreRender之前被解雇?
是的,它是在Page.PreRender之前调用的。
原因:每个数据绑定控件了DataSourceID属性的设置调用预先渲染事件的DataBind方法,

检查页面生命周期 http://msdn.microsoft.com/en-us/library/ms178472.aspx

http://dotnetshoutout.com/Data-Binding-Events-for-Data-Bound-Controls-in-ASPNet

由于负载事件被预渲染之前调用,当调用数据绑定方法然后在你的情况objectdatasource选择事件之前发射预渲染

+0

我假设如果第一次页面加载我们m一旦调用DropDownList1.DataBind()(在Page_Load()内部),那么DropDownList1将不会在PreRender事件中再次调用DataBind()?! – SourceC 2009-08-12 21:43:26

+1

是的,它不叫 – 2009-08-13 04:40:15

+0

thanx你的帮助 – SourceC 2009-08-13 18:43:00

相关问题