读书人

datalist的分页解决方法

发布时间: 2013-03-14 10:33:15 作者: rapoo

datalist的分页
XmlDataDocument doc = new XmlDataDocument();
doc.DataSet.ReadXml(Server .MapPath ("~/XMLFile.xml"));
if (doc.DataSet.Tables.Count != 0 && doc.DataSet.Tables[0].Rows.Count != 0)
{
DataList1.DataSource = doc.DataSet.Tables[0].DefaultView;
DataList1.DataBind();
}

数据多的时候我想分页,比如说每页10条记录,数据源在xml里。
[解决办法]
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = 分页大小;
pds.CurrentPageIndex = 当前页码;
pds.DataSource = doc.Tables[0].DefaultView;
DataList1.DataSource = pds;
DataList1.DataBind();

读书人网 >asp.net

热点推荐