自己写的Gridview分页功能

先写个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="首页&nbsp;"></asp:LinkButton>||
                <asp:LinkButton ID="btnPrev" runat="server" CommandArgument="prev" Font-Name="verdana"
                    Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text="&nbsp;前一页&nbsp;"></asp:LinkButton>|
                <asp:LinkButton ID="btnNext" runat="server" CommandArgument="next" Font-Name="verdana"
                    Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text="&nbsp;下一页&nbsp;"></asp:LinkButton>||
                <asp:LinkButton ID="btnLast" runat="server" CommandArgument="last" Font-Name="verdana"
                    Font-Size="8pt" ForeColor="Black" OnClick="PagerButtonClick" Text="&nbsp;末页&nbsp;"></asp:LinkButton>|&nbsp;
          <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>
       


posted @ 2008-07-02 10:43  xumingming  阅读(771)  评论(1编辑  收藏  举报