Tuesday, June 24, 2008

Datapager in asp.net 3.5

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">       
      th
      {
        background-color:#eef4fa;
        border-top:solid 1px #9dbbcc;
        border-bottom:solid 1px #9dbbcc;
      }
      .itemSeparator { border-right: 1px solid #ccc }
      .groupSeparator
      {
        height: 1px;
        background-color: #cccccc;
      }
    </style>

</head>
<body>
    <form id="form1" runat="server">
    <div>    
      <asp:DataPager runat="server" ID="BeforeListDataPager"
        PagedControlID="ProductsListView"
        PageSize="18">
        <Fields>
          <asp:NextPreviousPagerField ButtonType="Link"
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false"
            FirstPageText="« Prev" />
          <asp:NumericPagerField ButtonCount="10" />
          <asp:NextPreviousPagerField ButtonType="Link"
            ShowLastPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false"
            LastPageText=" Next »" />
            </Fields>
            </asp:DataPager>

      <asp:ListView ID="ProductsListView"
        DataSourceID="SqlDataSource1"
        GroupItemCount="3"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" id="tbl1" runat="server">
            <tr>
              <th colspan="5">PRODUCTS LIST</th>
            </tr>
            <tr runat="server" id="groupPlaceholder"></tr>
          </table>
        </LayoutTemplate>
        <GroupTemplate>
          <tr runat="server" id="tr1">
            <td runat="server" id="itemPlaceholder"></td>
          </tr>
        </GroupTemplate>
        <GroupSeparatorTemplate>
          <tr id="Tr1" runat="server">
            <td colspan="5">
                <div class="groupSeparator"><hr></div>
              </td>
          </tr>
        </GroupSeparatorTemplate>
        <ItemTemplate>
          <td id="Td1" align="center" runat="server">
            <asp:Label ID="lblcomp" Text='<%#Eval("companyname") %>' runat=server></asp:Label>
          </td>
        </ItemTemplate>
        <ItemSeparatorTemplate>
          <td id="Td2" class="itemSeparator" runat="server"> </td>
        </ItemSeparatorTemplate>
      </asp:ListView>
     <asp:DataPager runat="server" ID="Afterpagerlist"
        PagedControlID="ProductsListView"
        PageSize="18">
        <Fields>
          <asp:NextPreviousPagerField ButtonType="Link"
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false"
            FirstPageText="« Prev" />
          <asp:NumericPagerField ButtonCount="10" />
          <asp:NextPreviousPagerField ButtonType="Link"
            ShowLastPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false"
            LastPageText=" Next »" />
            </Fields>
            </asp:DataPager>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT top 200 [CompanyName] FROM [Registration]">
        </asp:SqlDataSource>   </div>
    </form>
</body>
</html>
Share:

0 Comments:

Post a Comment