0

我们可以将 DataPager 用于 DataList 吗?
我已经完成了,但是发生了以下异常!!!

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
4

1 回答 1

1

DataPager 需要分页控件来实现IPageableItemContainer接口。该接口在3.5中已经引入,所以旧控件没有实现该接口。

您的解决方案可以是创建一个虚拟控件,该控件实现此接口并根据要用于数据列表的数据源提供必要的分页逻辑。

编辑:顺便说一句,您始终可以使用 ListView 控件而不是 DataList。

于 2010-08-31T10:11:26.123 回答