如何开发一个可视webpart,在滚动gridview时按需加载列表项。
说明:首先在页面中加载webpart时,它将包含10个项目。当用户再次向下滚动滚动条时,10个项目将附加上述10个项目。这个过程应该一直持续到最后一个项目
我使用以下代码将列表项填充到GridView
:
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();
代码工作正常,但我有超过200项,我想加载基于滚动
请帮帮我!