濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 淺談VS中的DataPager分頁(yè)

淺談VS中的DataPager分頁(yè)

熱門標(biāo)簽:河南語(yǔ)音外呼系統(tǒng)公司 威海電銷 t3出行地圖標(biāo)注怎么做 關(guān)于宗地圖標(biāo)注技術(shù)規(guī)范 河北網(wǎng)絡(luò)回?fù)芡夂粝到y(tǒng) 400免費(fèi)電話怎么辦理 外呼電銷機(jī)器人軟件 寧夏機(jī)器人電銷 400電話辦理最優(yōu)質(zhì)

微軟的DataPager分頁(yè)功能很強(qiáng)大,不要設(shè)置數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程,只要添加個(gè)DataPager控件,關(guān)聯(lián)下要分頁(yè)的控件,簡(jiǎn)單設(shè)置就可以有不錯(cuò)的分頁(yè)效果。當(dāng)然要有更理想的效果還是要前臺(tái)和后臺(tái)處理下。

winform下的DataPager 顯示模式:

webForm下的樣式由TemplatePagerField,NextPreviousPagerField和NumericPagerField控制

通過(guò)設(shè)置上面幾個(gè)控件的配合也可以達(dá)到winForm下的效果,這3個(gè)控件中最重要的是TemplatePagerField控件。

下面簡(jiǎn)單看看TemplatePagerField控件可以怎么設(shè)置:

復(fù)制代碼 代碼如下:

  %@ Page language="VB" %>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
script runat="server">
  Protected Sub TemplatePagerField_OnPagerCommand(ByVal sender As Object, _
    ByVal e As DataPagerCommandEventArgs)
    ' Check which button raised the event
    Select Case e.CommandName
      Case "Next"
        Dim newIndex As Integer = e.Item.Pager.StartRowIndex + e.Item.Pager.PageSize
        If newIndex = e.TotalRowCount Then
          e.NewStartRowIndex = newIndex
          e.NewMaximumRows = e.Item.Pager.MaximumRows
        End If
      Case "Previous"
        e.NewStartRowIndex = e.Item.Pager.StartRowIndex - e.Item.Pager.PageSize
        e.NewMaximumRows = e.Item.Pager.MaximumRows
      Case "First"
        e.NewStartRowIndex = 0
        e.NewMaximumRows = e.Item.Pager.MaximumRows
    End Select
  End Sub
/script>
html xmlns="http://www.w3.org/1999/xhtml" >
  head id="Head1" runat="server">
    title>TemplatePagerField.OnPagerCommand Example/title>   
    style type="text/css">
      body    
      {
          text-align: center;
          font: 12px Arial, Helvetica, sans-serif;
      }
      .item
      {
        border: solid 1px #2F4F4F;
        background: #E6E6FA;
      }
    /style>
  /head>
  body>
    form id="form1" runat="server">
      h3>TemplatePagerField.OnPagerCommand Example/h3>
      asp:ListView ID="StoresListView"
        DataSourceID="StoresDataSource"
        runat="server">
        LayoutTemplate>
          table width="350" runat="server" id="tblStore">
            tr runat="server">
              th runat="server">ID/th>
              th runat="server">Store Name/th>
            /tr>
            tr id="itemPlaceholder" runat="server">
            /tr>
          /table>
         /LayoutTemplate>
         ItemTemplate>
          tr runat="server">
            td class="item">
              asp:Label ID="IDLabel" runat="server" Text='%#Eval("CustomerID") %>' />
            /td>           
            td align="left" class="item">
              asp:Label ID="NameLabel" runat="server" Text='%#Eval("Name")%>' />
            /td>
          /tr>
        /ItemTemplate>
      /asp:ListView>
      br />
      asp:DataPager runat="server"
        ID="ContactsDataPager"
        PageSize="30"
        PagedControlID="StoresListView">
        Fields>
          asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
            PagerTemplate>
              asp:LinkButton ID="FirstButton" runat="server" CommandName="First"
                Text="" Enabled='%# Container.StartRowIndex > 0 %>' />
              asp:LinkButton ID="PreviousButton" runat="server" CommandName="Previous"
                Text='%# (Container.StartRowIndex - Container.PageSize + 1) " - " (Container.StartRowIndex) %>'
                Visible='%# Container.StartRowIndex > 0 %>' />
              asp:Label ID="CurrentPageLabel" runat="server"
                Text='%# (Container.StartRowIndex + 1) "-" (IIf(Container.StartRowIndex + Container.PageSize > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize)) %>' />
              asp:LinkButton ID="NextButton" runat="server" CommandName="Next"
                Text='%# (Container.StartRowIndex + Container.PageSize + 1) " - " (IIf(Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize*2)) %>'
                Visible='%# (Container.StartRowIndex + Container.PageSize) Container.TotalRowCount %>' />
            /PagerTemplate>
          /asp:TemplatePagerField>
        /Fields>
      /asp:DataPager>    
      asp:SqlDataSource ID="StoresDataSource" runat="server"
            ConnectionString="%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT [CustomerID], [Name] FROM Sales.Store ORDER BY [Name]">
      /asp:SqlDataSource>
    /form>
  /body>
/html>

您可能感興趣的文章:
  • asp.net中讓Repeater和GridView支持DataPager分頁(yè)
  • asp.net實(shí)現(xiàn)簡(jiǎn)單分頁(yè)實(shí)例
  • asp.net gridview分頁(yè):第一頁(yè) 下一頁(yè) 1 2 3 4 上一頁(yè) 最末頁(yè)
  • ASP.NET MVC 5使用X.PagedList.Mvc進(jìn)行分頁(yè)教程(PagedList.Mvc)
  • Asp.net GridView使用大全(分頁(yè)實(shí)現(xiàn))
  • asp.net中g(shù)ridview的查詢、分頁(yè)、編輯更新、刪除的實(shí)例代碼
  • Asp.Net數(shù)據(jù)控件引用AspNetPager.dll分頁(yè)實(shí)現(xiàn)代碼
  • asp.net分頁(yè)控件AspNetPager的樣式美化
  • ASP.NET 高性能分頁(yè)代碼

標(biāo)簽:賀州 淮北 廣元 固原 咸寧 吉林 池州 樂(lè)山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《淺談VS中的DataPager分頁(yè)》,本文關(guān)鍵詞  淺談,中的,DataPager,分頁(yè),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《淺談VS中的DataPager分頁(yè)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于淺談VS中的DataPager分頁(yè)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    顺义区| 黑河市| 南通市| 沽源县| 开平市| 修武县| 临西县| 蓬莱市| 奉贤区| 双鸭山市| 方山县| 龙岩市| 青阳县| 通江县| 儋州市| 泰顺县| 青州市| 永胜县| 海门市| 大邑县| 黄平县| 周宁县| 石首市| 富川| 芜湖市| 清新县| 庆阳市| 肇源县| 如东县| 麻阳| 青冈县| 武川县| 灵台县| 普洱| 宿州市| 磐石市| 合阳县| 淮滨县| 墨江| 城固县| 永年县|