I'm trying to create a Server Control that will use a DataPager Control, but I'm having some difficulties with the PagerTemplate.
This is the DataPager control that I want to generate from a Server Control:
<asp:DataPager ID="myPager" PageSize="20" runat="server">
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<div class="counter">
<%# Container.StartRowIndex + 1 %> to
<%# ((Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)) %>
of <%# Container.TotalRowCount %> records
</div>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField ButtonType="link"
FirstPageText="first"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
RenderDisabledButtonsAsLabels="true" />
<asp:NumericPagerField ButtonCount="7" />
<asp:NextPreviousPagerField ButtonType="link"
LastPageText="last"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
I don't know how to create the PagerTemplate from code. I'm stuck in a part where I need to create a ITemplate, but I don't know how to work with it.
I've done some search but haven't found anything that could help me. I'm a bit newbie with Server Controls. I can do some simple ones, but templates are new to me.
Can anyone give me some help on this?
Thanks :)