我目前在我的 aspx 页面上有一个启用分页的 GridView 控件,我需要遍历整个行集合/计数来处理选定的记录。使用我当前的代码,它只会循环遍历 GridView 行的当前页面。
完成这项任务的最佳方法是什么?
这是我当前的代码:
ASPX 页面:
<asp:GridView ID="MyGridView" runat="server" AllowPaging="true" PageSize="20">
<Columns>
<!-- My Column list -->
</Columns>
</asp:GridView>
<asp:Button id="MyButton" runat="server" Text="Add" OnClick="MyButton_Click" />
后面的代码:
protected void MyButton_Click(object sender, EventArgs e)
{
for (int Count = 0; Count < MyGridView.Rows.Count; Count++)
{
//The row count is 20 and only contains the GridViewRow object in the current page view
//I want to retrieve the all GridViews rows so I can add them to a ReorderList control
}
}