【问题标题】:How to hide the paging row in the gridview when exporting in excel? [duplicate]在excel中导出时如何隐藏gridview中的分页行? [复制]
【发布时间】:2014-02-03 09:38:23
【问题描述】:

我正在使用 gridview 并添加了分页.. 在 excel 中导出时我不想要分页号 1 2 3..

<asp:GridView ID="mygrid" runat="server" AllowSorting="true" OnSorting="mygrid_Sorting"
            AllowPaging="true" AutoGenerateColumns="False" CssClass="Gridview" OnPageIndexChanging="mygrid_PageIndexChanging">
            <Columns>
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName"
                    HeaderStyle-Wrap="false">                 
                </asp:BoundField>
                <asp:BoundField DataField="AvailableQuantity" HeaderText="AvailableQuantity" SortExpression="AvailableQuantity"
                    HeaderStyle-Wrap="false">
                </asp:BoundField>
                <asp:BoundField DataField="ProductId" HeaderText="ProductId" SortExpression="ProductId"
                    HeaderStyle-Wrap="false">
                </asp:BoundField>
            </Columns>
        </asp:GridView>

<asp:Button ID="Button1" runat="server" Text="Export Data to Excel" OnClick="Button1_Click1" />

上面的网格允许分页,1 2 3是页码..导出到excel时显示分页码..如何删除excel中的分页码

【问题讨论】:

标签: c# asp.net excel gridview


【解决方案1】:

渲染前——禁用分页,绑定数据再渲染:

GridView1.AllowPaging = false;
GridView1.DataSource = ds; //Data Source
GridView1.DataBind();
GridView1.RenderControl(objHtmlTextWriter)

【讨论】:

    猜你喜欢
    • 2011-08-16
    • 2021-12-26
    • 2016-11-25
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多