DropdownList 分页绑定页数控制 如题,用dropdownlist跳转到第x页数,如何控制dropdownlist的绑定的页数(假设数据库页数比较多),有什么好的方法和思路吗?各位!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是说有多少页面 dropdown 里面显示多少值?先取得页面数 然后绑定上面 我是这样做的 Dropdownlist.datasource = dt(自己想想怎么寫..) 計算一下總共多少頁,生成1到總頁數的選項綁定dropdownlist 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页。有没有什么好方法 ,来这样控制 为什么不用链接?链接倒可以试一下如果是DropDownList的话 在selectedindexchange事件里每次都要动态绑定假设已经知道总页数以selectedvalue为中心,上下取你要的值,不足的自己写算法补 eg:selectedValue为10,则取0-20把这20个绑定上虽然麻烦,不过还是可以实现的 #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 .net调用SAP RFC 诡异问题:发布到生产系统,新代码不生效的问题 asp.net页面调用客户端exe程序的问题!!! asp.net中的标准控件不能拖动到页面上 asp.net导入Excel的数据到数据库中的问题 打印出现乱码?把DataGrid数据导入Excel时汉字全部变成乱码了怎么解决啊 在线等待 标志设计的颜色上应用 谁帮小妹一个忙? asp.net(C#)中“回车换行”怎么表示啊 能不能把数据绑定表达式的值,赋给变量??? 恳请大家帮忙 TreeView的动态绑定。
生成1到總頁數的選項
綁定dropdownlist
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页。有没有什么好方法 ,来这样控制
每次都要动态绑定假设已经知道总页数以selectedvalue为中心,上下取你要的值,不足的自己写算法补 eg:selectedValue为10,则取0-20把这20个绑定上虽然麻烦,不过还是可以实现的
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