我在datalist的底部加了分页的四个button:首页,上一页,下一页,尾页在做后台代码时,我想要一个效果,就是当在第一页的时候,首页和上一页的enable=false;在最后一页的时候,下一页和尾页的enable=false;想请教大家,该怎么做呢?无论是javascript代码也好,还是后台代码也好,因为是新手,所以想请大家说详细点,谢谢!!

解决方案 »

  1.   

    gridview 里面好做点儿吧、、、这个表示没在datalist里面弄过。
    试一试:CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("ckbox"); 对应着改改哈,比如 checkbox 改成 button 试一试
    然后加判断  if(){...}
      

  2.   

    private void SetLinkButton()
        {
            btnFirst.Enabled = true;
            btnPrev.Enabled = true;
            btnNext.Enabled = true;
            btnLast.Enabled = true;        if (txtPageIndex.Text == "1")
            {
                btnFirst.Enabled = false;
                btnPrev.Enabled = false;
            }
            Maticsoft.BLL.Products pBll = new Maticsoft.BLL.Products();
            if (txtPageIndex.Text == pBll.GetPagedListCount(int.Parse(txtPageSize.Text), string.Empty).ToString())
            {
                btnNext.Enabled = false;
                btnLast.Enabled = false;
            }
        }
      

  3.   

    用个AspNetPager控件不很简单吗,http://www.webdiyer.com/Controls/AspNetPager
      

  4.   

    给你一段代码自己模仿改一下。
    public void dataBindhypertensionhome()
            {
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource = B_hypertension.getHypertensionhome();            pds.AllowPaging = true;
                pds.PageSize = 1;
                int currentIndex = Convert.ToInt32(this.lbl_currentpage.Text) - 1;            pds.CurrentPageIndex = currentIndex;
                if (currentIndex == 0)
                {                this.lbt_previouspage.Enabled = false;            }
                else
                {
                    this.lbt_previouspage.Enabled = true;            }
                if (currentIndex == pds.PageCount - 1)
                {                this.lbt_nextpage.Enabled = false;            }
                else
                {
                    this.lbt_nextpage.Enabled = true;
                }
                this.lbl_totalpage.Text = pds.PageCount.ToString();            this.DataList1.DataSource = pds;
                this.DataList1.DataBind();
            }