先写个Pages.cs类 最好放在App_Code里
Code 然后在页面的cs文件里
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Pages.gridViewProperty(GridView1);
getData(); //此行是我的gridview方法 根据你实际的写
Pages.ShowStatsGrive(lblCurrentIndex, lblPageCount, this.GridView1);
}
}
protected void PagerButtonClick(object sender, EventArgs e)
{
Pages.PagerButtonClickGrive(sender, e, this.GridView1, lblCurrentIndex, lblPageCount);
getData();
}
在源里gridview代码的下面
</tr>
<tr>
<td align="right" bgcolor="#F3F8FC" style="height: 41px" ><table width="100%" border="0">
<tr>
<td align="left" style="width: 142px"></td>
<td align="right"> <asp:LinkButton ID="btnFirst" runat="server" CommandArgument="0" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text="首页 "></asp:LinkButton>||
<asp:LinkButton ID="btnPrev" runat="server" CommandArgument="prev" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 前一页 "></asp:LinkButton>|
<asp:LinkButton ID="btnNext" runat="server" CommandArgument="next" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 下一页 "></asp:LinkButton>||
<asp:LinkButton ID="btnLast" runat="server" CommandArgument="last" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 末页 "></asp:LinkButton>|
<asp:Label ID="lblCurrentIndex" runat="server" ForeColor="Black"></asp:Label>/<asp:Label ID="lblPageCount"
runat="server" ForeColor="Black"></asp:Label></td>
</tr>
</table> </td>
</tr>
Code 然后在页面的cs文件里
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Pages.gridViewProperty(GridView1);
getData(); //此行是我的gridview方法 根据你实际的写
Pages.ShowStatsGrive(lblCurrentIndex, lblPageCount, this.GridView1);
}
}
protected void PagerButtonClick(object sender, EventArgs e)
{
Pages.PagerButtonClickGrive(sender, e, this.GridView1, lblCurrentIndex, lblPageCount);
getData();
}
在源里gridview代码的下面
</tr>
<tr>
<td align="right" bgcolor="#F3F8FC" style="height: 41px" ><table width="100%" border="0">
<tr>
<td align="left" style="width: 142px"></td>
<td align="right"> <asp:LinkButton ID="btnFirst" runat="server" CommandArgument="0" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text="首页 "></asp:LinkButton>||
<asp:LinkButton ID="btnPrev" runat="server" CommandArgument="prev" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 前一页 "></asp:LinkButton>|
<asp:LinkButton ID="btnNext" runat="server" CommandArgument="next" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 下一页 "></asp:LinkButton>||
<asp:LinkButton ID="btnLast" runat="server" CommandArgument="last" Font-Name="verdana"
Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text=" 末页 "></asp:LinkButton>|
<asp:Label ID="lblCurrentIndex" runat="server" ForeColor="Black"></asp:Label>/<asp:Label ID="lblPageCount"
runat="server" ForeColor="Black"></asp:Label></td>
</tr>
</table> </td>
</tr>
来源:https://www.cnblogs.com/xumingming/archive/2008/07/02/1233783.html