0

How to develope a visual webpart that loads list items on demand when scrolling the gridview.

Description: first when the webpart is loaded in the page, it will come with 10 items. when the user is scrolling down the scrollbar again 10 items to be append with the above 10 items. This process should should continue till the last item

I am populating list items to GridView with the following code:

   SPQuery query = new SPQuery();
   query.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Batch</Value></Eq></Where>";

    SPList empList = web.GetList(Urlhere);
    SPListItemCollection queryResults = empList.GetItems(query);


    DataTable dt = new DataTable();

   dt.Columns.Add("ID", typeof(string));
   dt.Columns.Add("Name", typeof(string));


   if (queryResults.Count > 0)
       {
         foreach (SPListItem item in queryResults)
          {
              DataRow dr = dt.NewRow();                                                             
              dr["ID"] = item["ID"].ToString();
              dr["Name"] = item["iv3h"].ToString();
              dt.Rows.Add(dr);
           }
        }                
        BoundField bf = new BoundField();                       
        bf.DataField = "ID";
        bf.HeaderText = "ID";
        GridViewEarningLine.Columns.Add(bf);

        bf = new BoundField();
        bf.DataField = "Name";
        bf.HeaderText = "Name"; 
        GridViewEarningLine.Columns.Add(bf);

        GridViewEarningLine.DataSource = dt;

        GridViewEarningLine.DataBind();     

the code is working perfect but I got mare than 200 items and I want to load based on scroll

Please help me!

John Champion
  • 147
  • 2
  • 2
  • 12

0 Answers0