The data source does not support server-side data paging

后端 未结 8 1239
眼角桃花
眼角桃花 2020-11-29 07:20

I have a GridView on my screen and need it to allow paging.

Markup:



        
8条回答
  •  醉梦人生
    2020-11-29 07:42

    You can use generic List also. See the sample code snippet:

    public List GetContactList(int startindex)
    {
    
        string path = Server.MapPath("~/contacts.xml");
        XDocument xd = XDocument.Load(path);
        IEnumerable results = (from items in xd.Elements("Company").Elements("Contact")
                       select new Company
                       {
                           Id = items.Element("ID").Value,
                           Photo = (string)items.Element("photo").Value,
                           Name = (string)items.Element("Name").Value,
                           BloodGroup = (string)items.Element("Bg").Value,
                           Dob = (string)items.Element("dob").Value,
                           Anniversery = (string)items.Element("avd").Value,
                           Mobile = (string)items.Element("cnum").Value,
                           designation = (string)items.Element("desig").Value,
                           Team = (string)items.Element("team").Value
                       }).Skip(startindex*10).Take(10);
        return (List) results;
    }
    

    You can also use DataSet/DataTable instead of DataReader.

提交回复
热议问题