我正在使用Twitter Bootstrap和ASP.Net C#Webforms构建一个网站.我的页面上有一个ListView,它绑定了一个DataPager,但我需要改变.Net呈现DataPager的HTML的方式.
目前,所有寻呼机项目都显示如下:
<div class="clearfix pagination pagination-centered"> <span id="cpBody_dpListing"> <a class="aspNetDisabled">First</a> <span>1</span> <a href="javascript:__doPostBack('ctl00$cpBody$dpListing$ctl02$ctl01','')">2</a> <a href="javascript:__doPostBack('ctl00$cpBody$dpListing$ctl03$ctl00','')">Last</a> </span> </div>
Run Code Online (Sandbox Code Playgroud)
但是我需要将所有项目包装在无序列表中,而不是跨度和标签.我目前的加价看起来像这样:
<div class="clearfix pagination pagination-centered">
<asp:DataPager ID="dpListing" runat="server" PagedControlID="lvListing" PageSize="10" OnPreRender="dpListing_PreRender">
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<asp:BulletedList ID="listPages" runat="server" DisplayMode="LinkButton" OnClick="listPages_Click"></asp:BulletedList>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="true" ShowNextPageButton="false" ShowPreviousPageButton="false" />
<asp:NumericPagerField PreviousPageText="< Prev 10" NextPageText="Next 10 >" ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="true" ShowNextPageButton="false" ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
Run Code Online (Sandbox Code Playgroud)
我不知何故需要覆盖NextPreviousPagerField和NumericPagerField,因此它们输出<li>标签而不是<span>和<a>.