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: 开发者_如何学GoControl '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
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.
精彩评论