【问题标题】:Dynamically setting pageno and maxrow to datapager control using a stored procedure使用存储过程将 pageno 和 maxrow 动态设置为 datapager 控件
【发布时间】:2011-10-28 15:17:39
【问题描述】:

我有一个 ListView,我正在使用 DataPager 进行分页。我正在使用存储过程来返回分页数据。存储过程返回总行数作为输出参数。

我的存储过程是

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.based 中设置分页。

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    你可以这样做.....在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

    希望对你有帮助……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 2021-01-25
      • 2014-04-14
      • 1970-01-01
      相关资源
      最近更新 更多