【原創】asp.net webdiyer AspNetPager控制項分頁碼改變時,序號列從新從1開始問題的解決

來源:互聯網
上載者:User

標籤:

 

長話短說,首先看repeater 配合 webdiyer AspNetPager使用時webdiyer AspNetPager屬性設定代碼。

 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CssClass="paginator" OnPageChanging="AspNetPager1_PageChanging"
        CurrentPageButtonClass="cpb" FirstPageText="首頁" LastPageText="尾頁" NextPageText="下一頁"
        PrevPageText="上一頁" ShowMoreButtons="true" ShowCustomInfoSection="Right" CustomInfoTextAlign="Right"
        LayoutType="Table" ShowPageIndexBox="Never" SubmitButtonText="跳轉" PageSize="18"
        CustomInfoHTML="共%PageCount%頁/第%CurrentPageIndex%頁,每頁%PageSize%條,總記錄數:%RecordCount%"
        UrlPaging="True" AlwaysShow="true">
    </webdiyer:AspNetPager>

 

從 上邊代碼可看出,此分頁傳值方式為URL傳值。當使用<%#Container.ItemIndex+1%>來產生序號時,第二頁序號依然從1開始,理想情況下的話,應該從3開始。

 

 

 

   序號可以這樣產生,

       public string ReturnOrder(int xmid)
        {
            int page = 0;
            if (Request.QueryString["page"] != null)
            {
                page = int.Parse(Request.QueryString["page"]) - 1;
            }

            int strXM = page * AspNetPager1.PageSize + xmid;
            return strXM.ToString();
         }

前台 綁定代碼:

    <td style="white-space: nowrap" align="center">
          <%# ReturnXM(Container.ItemIndex+1)%>
          </td>

 

效果:

【原創】asp.net webdiyer AspNetPager控制項分頁碼改變時,序號列從新從1開始問題的解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.