使用存储过程动态地将pageno和maxrow设置为datapager控件

时间:2011-10-28 15:17:40

标签: asp.net

我有一个ListView,我使用DataPager.i进行分页,使用存储过程返回分页Data.Stored过程返回总行数为out paramater。

我的存储过程是

crate procedure [dbo].[Sp_ProductList]
@Id int,
@Country int,
@state int,
@City int,
@Group int,
@pageno int,
@pageCount int out
as begin
--custom search
end
我的列表视图布局中的

  <asp:ListView ID="LstCatalogue" runat="server" OnSelectedIndexChanged="LstCatalogue_SelectedIndexChanged">
    <LayoutTemplate>
<div id="productContent" class="center_Productcontent">
                <div runat="server" id="ItemPlaceholder"></li>
            </div>
    <div class="Pager">
        <asp:DataPager ID="pgrUpper" runat="server" PageSize="9" PagedControlID="LstCatalogue">
             <Fields>
             <asp:NextPreviousPagerField ButtonCssClass="command" FirstPageText="First" PreviousPageText="Previous" RenderDisabledButtonsAsLabels="true" RenderNonBreakingSpacesBetweenControls="true"  ShowFirstPageButton="true" ShowNextPageButton="false" ShowLastPageButton="false"  ShowPreviousPageButton="true" />
             <asp:NumericPagerField ButtonCount="10" NumericButtonCssClass="command" CurrentPageLabelCssClass="current" NextPreviousButtonCssClass="command" RenderNonBreakingSpacesBetweenControls="true" />
             <asp:NextPreviousPagerField ButtonCssClass="command" NextPageText="Next" LastPageText="Last" RenderDisabledButtonsAsLabels="true" ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowNextPageButton="true" ShowLastPageButton="true" />
        </Fields>
      </asp:DataPager>
            </div>


        </LayoutTemplate>
    </asp:ListView>

我的问题是如何根据存储过程中的分页数据在datapager中设置分页。

1 个答案:

答案 0 :(得分:0)

你可以这样做.....在datapager控件.....

    <asp:DataPager ID="dataPagerNumeric" 
                 runat="server" PageSize="5">
                   <Fields>
                        <asp:NumericPagerField ButtonCount="5" 
                        NumericButtonCssClass="numeric_button" 
                        CurrentPageLabelCssClass="current_page"
                                        NextPreviousButtonCssClass="next_button" />
                   </Fields>
                </asp:DataPager>
              <td colspan="4" class="number_of_record">
                  <asp:DataPager ID="dataPageDisplayNumberOfPages" 
                  runat="server" PageSize="5">
                    <Fields>
                           <asp:TemplatePagerField>
                                <PagerTemplate>
                                     <span style="color: Black;">Records:
                                           <%# Container.StartRowIndex >= 0 ? 
                                           (Container.StartRowIndex + 1) : 0 %> -
                                           <%# (Container.StartRowIndex + 
                    Container.PageSize) 
                                           > Container.TotalRowCount ? 
                    Container.TotalRowCount : 
                                           (Container.StartRowIndex + 
                    Container.PageSize)%> of
                                           <%# Container.TotalRowCount %>
                                                </span>
                                            </PagerTemplate>
                                        </asp:TemplatePagerField>
                                    </Fields>
                                </asp:DataPager>
                            </td>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>

请您浏览此链接For more Info

我希望它会帮助你...