I'm trying to convert a datapager that references a ListView all inside a composite control. The ListView correctly displays the full list so now I need to reference a pager to it. But for some reason the datapager isn't being displayed or paging the ListView. Also the DataPager must use an OnPreRender method to databind the ListView to it so I was wondering how to add that method too.
The design for the DataPager is:
<div class="ctrlArticleList_pageNavigationTop">
<asp:DataPager PageSize="10" ID="dataPagerTop" OnPreRender="DataPager_PreRender" PagedControlID="lstArticle"
runat="server">
<Fields>
<asp:NumericPagerField NextPreviousButtonCssClass="ctrlArticleList_pagerNormal"
CurrentPageLabelCssClass="ctrlArticleList_pagerCurrent" NumericButtonCssClass="ctrlArticleList_pagerNormal"
ButtonCount="5" PreviousPageText="<< previous" NextPageText="next >>" />
</Fields>
</asp:DataPager>
</div>
To convert this in the composite control which only shows 'hello':
ListView lstArticle = new ListView();
lstArticle.ID = "lstArticle";
DataPager dataPager = new DataPager() { PageSize = 10, ID = "dataPagerTop", PagedControlID = "lstArticle" };
//dataPager.PreRender = "DataPager_PreRender";
NumericPagerField pagerField = new NumericPagerField()
{
NextPreviousButtonCssClass = cssClassPagerNormal,
CurrentPageLabelCssClass = cssClassPagerCurrent,
NumericButtonCssClass = cssClassPagerNormal,
ButtonCount = buttonCount,
PreviousPageText = previousPageText,
NextPageText = nextPageText
};
HtmlGenericControl divNavigateTop = new HtmlGenericControl("div");
divNavigateTop.Attributes.Add("class", cssClassNavigationTop);
divNavigateTop.InnerText = "Hello";
dataPager.Fields.Add(pagerField);
divNavigateTop.Controls.Add(dataPager);
divBody.Controls.Add(divNavigateTop);