我们可以为DataList使用DataPager吗?
我已经完成了,但发生了以下异常!
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Control 'DataList1' does not implement IPageableItemContainer.]
System.Web.UI.WebControls.DataPager.FindPageableItemContainer() +500609
System.Web.UI.WebControls.DataPager.OnInit(EventArgs e) +33
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378发布于 2010-08-31 18:11:26
DataPager需要分页控件来实现IPageableItemContainer接口。该接口是在3.5中引入的,因此旧的控件不会实现该接口。
您的变通办法是创建一个实现此接口的虚拟控件,并根据要用于数据列表的数据源提供必要的分页逻辑。
编辑:顺便说一句,你可以用ListView控件代替DataList。
https://stackoverflow.com/questions/3605291
复制相似问题