• 刷新的分页代码


     int pc = 2;
    protected void Page_Load(object sender, EventArgs e)
    {

    //控制菜单
    object obj = Request.QueryString["temp"];
    if (obj == null)
    {
    ViewState[
    "temp"] = 1;
    }
    else
    {
    ViewState[
    "temp"] = obj;
    }
    Page.RegisterStartupScript(
    "", "<script>yangshi(" + Convert.ToInt32(ViewState["temp"]) + ");</script>");

    //注册ajaxPro,括号中的参数是当前的类名
    AjaxPro.Utility.RegisterTypeForAjax(typeof(WXContract));
    if (!IsPostBack)
    {
    Server.Execute(
    "LoginAPI.aspx");

    string Cookie = Request.Cookies["username"].Value;
    string[] Cookies = Cookie.Split(',');
    //a1,userid=54,departid=39,username1=a1,chakanlist=False,TouXiang=,depname=��Ӫ��

    ViewState[
    "uid"] = Cookies[1].Split('=')[1];
    ViewState[
    "did"] = Cookies[2].Split('=')[1];
    ViewState[
    "PageIndex"] = 0;
    ViewState[
    "PageCount"] = ContractManageBLL.GetContractInfoList(pc, 0, Convert.ToInt32(ViewState["uid"]), Convert.ToInt32(ViewState["temp"]), Convert.ToInt32(ViewState["did"])).Tables[0].Rows[0][0];
    ShowDataSource( Convert.ToInt32(ViewState[
    "PageCount"]),Convert.ToInt32(ViewState["PageIndex"]));
    }
    }
    //窗体加载时显示合同列表
    public void ShowDataSource(int zs, int ys)
    {
    lblShow.Text
    = "总共<font color='red'>" + zs + "</font>条记录 第<font color='red'>" + (ys+1) + "</font>页";
    zs
    = (int)System.Math.Ceiling(Convert.ToDouble(zs) / pc);
    lblShow.Text
    += "/共<font color='red'>" + zs + "</font>页";
    dlHTList.DataSource
    = ContractManageBLL.GetContractInfoList(pc, ys, Convert.ToInt32(ViewState["uid"]), Convert.ToInt32(ViewState["temp"]), Convert.ToInt32(ViewState["did"])).Tables[1];
    dlHTList.DataBind();

    }

    //首页
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
    ViewState[
    "PageIndex"] = 0;
    ShowDataSource(Convert.ToInt32(ViewState[
    "PageCount"]), 0);
    }
    //末页
    protected void LinkButton4_Click(object sender, EventArgs e)
    {

    int res = Convert.ToInt32(ViewState["PageCount"]);
    int last = (int)System.Math.Ceiling(Convert.ToDouble(res) / pc);
    ViewState[
    "PageIndex"] = (last - 1);
    ShowDataSource(res, (last
    -1));
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
    //上一页
    if ((int)ViewState["PageIndex"]>0)
    {
    ViewState[
    "PageIndex"] = (int)ViewState["PageIndex"] - 1;
    ShowDataSource(Convert.ToInt32(ViewState[
    "PageCount"]), Convert.ToInt32(ViewState["PageIndex"]));
    }
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
    int res = Convert.ToInt32(ViewState["PageCount"]);
    int last = (int)System.Math.Ceiling(Convert.ToDouble(res) / pc);
    //下一页
    if ((int)ViewState["PageIndex"]<last-1)
    {
    ViewState[
    "PageIndex"] = (int)ViewState["PageIndex"] + 1;
    ShowDataSource((
    int)ViewState["PageCount"], (int)ViewState["PageIndex"]);
    }
    }

      

  • 相关阅读:
    CopyOnWriteArrayList设计思路与源码分析
    点击页面按钮以excel保存到本地
    上传图片
    关于重复点击的
    去首尾空格还有换行问题//把数字换位大写字母//向后台传输数据
    判断输入的时间与当前的时间(判断时间是今天还是以前的)
    前端的一些小技巧
    git 操作大全
    移动web开发常见问题解决方案
    响应式布局
  • 原文地址:https://www.cnblogs.com/0banana0/p/2159656.html
Copyright © 2020-2023  润新知