List<Object>集合绑定AspnetPage List集合绑定AspnetPage ,List集合 里头有一些数据 需要分页但是 这个集合不是从数据库中读到的 所以 不知道怎么绑定到AspnetPage控件,如果大家有好的方法或者其他的分页方式又或者是自己写的方法 都可以,谢谢各位啦。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.webdiyer.com/AspNetPagerDemo/default.aspx自己找 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataBind(); } } private void DataBind() { List<string> list = new List<string>(); list.Add("1"); list.Add("2"); list.Add("3"); list.Add("4"); list.Add("5"); list.Add("6"); this.GridView1.DataSource = GetPageList(list, 2, 2); this.GridView1.DataBind(); } private List<string> GetPageList(List<string> list, int PageIndex, int PageSize) { if (PageIndex == 0)//如果将其全部返回 { return list; } List<string> newlist = new List<string>();//新的集合 int rowbegin = (PageIndex - 1) * PageSize;//起始行数 int rowEnd = PageIndex * PageSize;//结束行数 if (rowbegin >= list.Count)//如果起始行数大于总数 返回空 { return newlist; } for (int i = rowbegin; i < rowEnd ; i++) { newlist.Add(list[i]);// } return newlist; } protected void AspNetPager1_PageChanged(object sender, EventArgs e){ dataBind();}protected void dataBind(){ PagedDataSource pds = new PagedDataSource(); //要分页的list列表 List<Msg> list = MsgManager.getList(); AspNetPager1.RecordCount = list.Count; pds.DataSource = list; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; this.DataList1.DataSource = pds; this.DataList1.DataBind();} JS中变量的作用域?? 关于submit提交表单键提交的值 使用类遇到的问题 |zyciis| 老问题,如何改写一个服务器控件生成的HTML呢 谢谢 一个小问题,大家帮看下。谢谢 在windows验证模式下,如何实现多网站见跳转只让用户输入一次用户名密码? 奇怪的问题,求揭秘者!!! 请教下 asp.net 怎么解析 json 数据 利用ADO.NET生成XML的问题? 页面采用了框架技术,在框架中的.aspx页面中有一个按钮,想达到点击该按钮之后在框架之外弹出一个新的窗口,同时给新窗口传递一个参数, treeview 变色 为什么层的位置会随其中的表格的样式而变化
自己找
{
if (!IsPostBack)
{
DataBind();
}
}
private void DataBind()
{
List<string> list = new List<string>();
list.Add("1");
list.Add("2");
list.Add("3");
list.Add("4");
list.Add("5");
list.Add("6"); this.GridView1.DataSource = GetPageList(list, 2, 2);
this.GridView1.DataBind();
}
private List<string> GetPageList(List<string> list, int PageIndex, int PageSize)
{
if (PageIndex == 0)//如果将其全部返回
{
return list;
}
List<string> newlist = new List<string>();//新的集合
int rowbegin = (PageIndex - 1) * PageSize;//起始行数
int rowEnd = PageIndex * PageSize;//结束行数
if (rowbegin >= list.Count)//如果起始行数大于总数 返回空
{
return newlist;
}
for (int i = rowbegin; i < rowEnd ; i++)
{
newlist.Add(list[i]);//
}
return newlist;
}
{
dataBind();
}protected void dataBind()
{
PagedDataSource pds = new PagedDataSource();
//要分页的list列表
List<Msg> list = MsgManager.getList(); AspNetPager1.RecordCount = list.Count;
pds.DataSource = list;
pds.AllowPaging = true;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.PageSize = AspNetPager1.PageSize;
this.DataList1.DataSource = pds;
this.DataList1.DataBind();
}