In one of my websites I have several pages that do data fetching and presentation.
In these pages the content is retrieved from some data source and presented in a listview (very vanilla operation).
Now, I would like to add a DataPager to these pages (actually user controls), but I don't want to repeat the same code over and over again.
My pager is going to look exactly the same for all data operations that I'm performing. So, I just placed it in a separate user control and exposed the page size and the page control id as public properties.
The problem that I'm facing is that when I load any page with my DataPager wrapper control I get the following exception:
System.InvalidOperationException: No IPageableItemContainer was found. Verify that either the DataPager is inside an IPageableItemContainer or PagedControlID is set to the control ID of an IPageableItemContainer.
protected void InitializePagerProperties(int pageSize, string pagedControl, bool isVisible)
{
//parameters are coming from the public properties
MyDataPager.PageSize = pageSize;
MyDataPager.PagedControlID = pagedControl;
MyDataPager.Visible = isVisible;
}