GridView分页方法
<PagerTemplate>
<asp:LinkButton CommandName="Page" CommandArgument="First" ID="LinkButton1" runat="server">第一页</asp:LinkButton>
<asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server">上一页</asp:LinkButton>
<asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server">下一页</asp:LinkButton>
<asp:LinkButton CommandName="Page" CommandArgument="Last" ID="LinkButton4" runat="server">最后一页</asp:LinkButton>
<font color="black">[当前是第 <font color="red"><%= GridView1.PageIndex * GridView1.PageSize+1 %> - <%= GridView1.PageIndex * GridView1.PageSize + GridView1.PageSize %></font> ]条</font>
<font color="black">[共 <font color="red"><%= iRecordCount %></font> 条记录]</font>
</PagerTemplate>
在代码中加入下面代码
public int iRecordCount = 0;
protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
iRecordCount=e.AffectedRows;
}