Data binding 如何将网格视图(AllowPaging=true)中的所有行放入DataTable?(asp.net c#)

Data binding 如何将网格视图(AllowPaging=true)中的所有行放入DataTable?(asp.net c#),data-binding,datagridview,datatable,data-paging,Data Binding,Datagridview,Datatable,Data Paging,我想将数据从网格视图检索到数据表中。 问题是我的网格视图有数据分页器,当我想将数据抓取到我的数据表=>时,它只抓取第一页 以下是我的代码: <asp:GridView ID="GVQuery" runat="server" AllowSorting="True" CssClass="query" GridLines="None" EmptyDataText="-" AllowPaging="True" PagerSettings-Mode=

我想将数据从网格视图检索到数据表中。 问题是我的网格视图有数据分页器,当我想将数据抓取到我的数据表=>时,它只抓取第一页 以下是我的代码:

<asp:GridView ID="GVQuery" runat="server" AllowSorting="True" CssClass="query" GridLines="None" EmptyDataText="-"

                        AllowPaging="True" PagerSettings-Mode="Numeric" DataSourceID="SqlDS" AutoGenerateColumns="False">
                        <Columns>
                            <asp:BoundField DataField="Date" DataFormatString="{0:yyyy/MM/dd}" HeaderText="Date" SortExpression="Date" />
                            <asp:BoundField DataField="Time" DataFormatString="{0:t}" HeaderText="Time" SortExpression="Time" />
                            <asp:BoundField DataField="Balance" DataFormatString="{0:c0}" HeaderText="Balance" SortExpression="Balance">
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Obligee" DataFormatString="{0:c0}" HeaderText="obligee" SortExpression="Obligee">
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Debtor" DataFormatString="{0:c0}" HeaderText="Debtor" SortExpression="Debtor">
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
                            </asp:BoundField>
                            <asp:BoundField DataField="DocSerial" DataFormatString="" HeaderText="DocSerial" SortExpression="DocSerial" />
                            <asp:BoundField DataField="TransactionNo" DataFormatString="" HeaderText="TransNo" ConvertEmptyStringToNull="False" SortExpression="TransactionNo" />
                            <asp:BoundField DataField="TransactionType" DataFormatString="" HeaderText="TransType" SortExpression="TransactionType" />
                            <asp:BoundField DataField="PaymentType" HeaderText="PeymentType" SortExpression="PaymentType" />
                            <asp:BoundField DataField="BranchName" DataFormatString="" HeaderText="BranchName" SortExpression="BranchName" />
                            <asp:BoundField DataField="PayerName" DataFormatString="" HeaderText="Payer" SortExpression="PayerName" />
                            <asp:BoundField DataField="DocDescription" DataFormatString="{0:0c0}" HeaderText="DocDesc" SortExpression="DocDescription" />
                        </Columns>
                        <RowStyle CssClass="query-row" />
                        <AlternatingRowStyle CssClass="query-alternate-row" />
                        <PagerStyle CssClass="pager" />
                        <SortedAscendingHeaderStyle CssClass="sorted-asc-header" />
                        <SortedAscendingCellStyle CssClass="sorted-asc" BackColor="#12184a" ForeColor="#bddded" />
                        <SortedDescendingHeaderStyle CssClass="sorted-desc-header" />
                        <SortedDescendingCellStyle CssClass="sorted-desc" BackColor="#12184a" ForeColor="#bddded" />
                        <PagerSettings FirstPageText="Start" LastPageText="End" Position="Bottom" Mode="NumericFirstLast" PageButtonCount="40" />
                        <PagerStyle CssClass="pager" />
                        <EmptyDataTemplate>
                            <p>Nothing to Show</p>
                        </EmptyDataTemplate>
                    </asp:GridView>

没什么可展示的

我就是这样将数据检索到数据表的:

DataTable dt = new DataTable();
        for (int i = 0; i < GVQuery.Columns.Count; i++)
        {
            dt.Columns.Add("column" + i.ToString());
            dt.Columns[i].Caption = GVQuery.Columns[i].HeaderText.ToString();
        }
        foreach (GridViewRow row in GVQuery.Rows)
        {
            DataRow dr = dt.NewRow();
            for (int j = 0; j < GVQuery.Columns.Count; j++)
            {
                dr["column" + j.ToString()] = row.Cells[j].Text;
            }

            dt.Rows.Add(dr);
        }
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ColumnName = dt.Columns[i].Caption;
        }
DataTable dt=newdatatable();
for(int i=0;i