翻页事件

前端页面:

 <asp:Label
                ID="l_CurrentPage" runat="server" Font-Size="10pt"></asp:Label></span><span style="font-size: 10pt">
                </span>
            <asp:Label ID="l_TotalPage" runat="server" Font-Size="10pt"></asp:Label><span style="font-size: 10pt">
                <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="first" OnClick="ShowPage">首页</asp:LinkButton>
                <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument="prev" OnClick="ShowPage">前一页</asp:LinkButton>
                <asp:LinkButton ID="LinkButton3" runat="server" CommandArgument="next" OnClick="ShowPage">后一页</asp:LinkButton>
                <asp:LinkButton ID="LinkButton4" runat="server" CommandArgument="last" OnClick="ShowPage">末页</asp:LinkButton></span> 

后端代码:

 #region ShowPage    GridView翻页事件
    protected void ShowPage(object sender, EventArgs e)
    {
        string arg = ((LinkButton)sender).CommandArgument.ToString();
        switch (arg)
        {
            case "first":
                { gv_Country.CurrentPageIndex = 0; }
                break;
            case "prev":
                if (gv_Country.CurrentPageIndex > 0)
                { gv_Country.CurrentPageIndex -= 1; }
                break;
            case "next":
                if (gv_Country.CurrentPageIndex < (gv_Country.PageCount - 1))
                { gv_Country.CurrentPageIndex += 1; }
                break;
            case "last":
                gv_Country.CurrentPageIndex = (gv_Country.PageCount - 1);
                break;
            default:
                return;
        }
        f_databind();
    }//ShowPage
    #endregion

阅读更多
文章标签: server asp object string
个人分类: 代码_用户界面
想对作者说点什么? 我来说一句

Jsonp+asp.net

2013年08月13日 432KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭