如题,用dropdownlist跳转到第x页数,如何控制dropdownlist的绑定的页数(假设数据库页数比较多),有什么好的方法和思路吗?各位!!

解决方案 »

  1.   

    是说有多少页面 dropdown 里面显示多少值?先取得页面数 然后绑定上面 我是这样做的
      

  2.   

    Dropdownlist.datasource = dt(自己想想怎么寫..)
      

  3.   

    計算一下總共多少頁,
    生成1到總頁數的選項
    綁定dropdownlist
      

  4.   


     private void BindDropDownList()
        {
            for (int i = 1; i <=(int)ViewState["PageCount"]; i++)
            {
                
                DropDownList1.Items.Add(new ListItem("第"+i+"页",i.ToString()));
            }
            DropDownList1.SelectedIndex = (int)ViewState["CurrentPage"]-1;
        }
    问题是PageCount太大,直接绑定的话会消耗很大内存,我想要达到这样一个效果,只显示当前页附近的20个页数
    比如当前是第20页,dropdownlist选项有第10页到第30的选项,第31页做省略好表示!点下一页,再重新绑定当前页附近的20页。有没有什么好方法 ,来这样控制
      

  5.   

    为什么不用链接?链接倒可以试一下如果是DropDownList的话 在selectedindexchange事件里
    每次都要动态绑定假设已经知道总页数以selectedvalue为中心,上下取你要的值,不足的自己写算法补 eg:selectedValue为10,则取0-20把这20个绑定上虽然麻烦,不过还是可以实现的
      

  6.   

    #region 下拉分页事件
            protected void DropDownList_PageCount_SelectedIndexChanged(object sender, EventArgs e)
            {
                try
                {
                    this.GridView1.PageIndex = Convert.ToInt32(this.DropDownList_PageCount.SelectedValue.ToString()) - 1;
                    this.DropDownList_PageCount.SelectedValue = (this.GridView1.PageIndex + 1).ToString();
                    this.CheckBox_All.Checked = false;
                    BagBind();//重新绑定GridView数据的函数            }
                catch
                { }
            }
            #endregion