使用 DataPager 作为数据列表?
我们可以将 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
Can we use a DataPager for a DataList?
I've done it but the following exception has occurred !!!
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DataPager 需要分页控件来实现 IPageableItemContainer 接口。该接口已在3.5中引入,因此旧控件不实现该接口。
您的解决方案可以是创建一个虚拟控件,该控件实现此接口并根据要用于数据列表的数据源提供必要的分页逻辑。
编辑:顺便说一句,您始终可以使用 ListView 控件而不是 DataList。
DataPager needs the paged control to implement IPageableItemContainer interface. The interface has been introduced in 3.5, so old controls don't implement this interface.
Workaround solution for you can be to create a dummy control that implements this interface and provides necessary paging logic based on data source to be used for your data list.
EDIT: BTW, you can always use ListView control instead of DataList.