Binding Share point list data to Grid View.

Hi,

I have one requirement List throttling , I'm bind list data to Grid view  through SPQuery , but in that grid view having page navigation. i want each page 100 records . how to set the share point list data to each page 100 items through SPQuery 

January 21st, 2015 10:04am

Hello,

You need to define pagesize property of gridview to set limit. Refer below links for your ref:

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagesize.aspx

And here is code snippet to implementing paging in grid:

http://blog.techperspect.com/2011/03/step-by-step-guide-to-implement-paging.html

Hope it could help

Free Windows Admin Tool Kit Click here and download it now
January 21st, 2015 10:25am

Hi 

You can use the ListItemCollectionPosition class to implement paging list item.Below is the link for the same.

https://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx

January 21st, 2015 1:31pm

try these links:

http://blog.techperspect.com/2011/03/step-by-step-guide-to-implement-paging.html

https://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx

---------------------------------------------------------------------------------------------------------------------------

Please mark as answer if you find it useful else vote for it if it is close to answer..happy sharepointing

Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2015 7:20am

Hi,

For me the best way is collect all records from the list and fill a DataTable.

After that you have in your side the Source and now you have the possibility to do whatever you want.

January 27th, 2015 3:20pm

You could take ObjectDataSource with the following code:

SPQuery query = new SPQuery();
string fields = @"<FieldRef Name='CustomerID'/><FieldRef Name='CompanyName'/>";
query.ViewFields = fields;
query.RowLimit = 100;

int i = 1;
do
{
    SPListItemCollection coll = list.GetItems(query);
    dt = coll.GetDataTable();
    dt.TableName = "Page" + i.ToString();
    ds.Tables.Add(dt);
    query.ListItemCollectionPosition = coll.ListItemCollectionPosition;
    i++;
} while (query.ListItemCollectionPosition != null);

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2015 3:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics