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里。

解决方案 »

  1.   

            PagedDataSource pds = new PagedDataSource();
            pds.AllowPaging = true;
            pds.PageSize = 分页大小;
            pds.CurrentPageIndex = 当前页码;
            pds.DataSource = doc.Tables[0].DefaultView;
            DataList1.DataSource = pds;
            DataList1.DataBind();
      

  2.   

    PagedDataSource pds = new PagedDataSource();
            pds.AllowPaging = true;
            pds.PageSize = 分页大小;
            pds.CurrentPageIndex = 当前页码;
            pds.DataSource = doc.Tables[0].DefaultView;
            DataList1.DataSource = pds;
            DataList1.DataBind();