SPGridView – as generic webpart for any listview with sorting of columns

As SharePoint developer, we need to list the items as webpart, we can list them by using asp.net GridView control, but in general cases sorting is also required. ASP.NET gridview can serve this functionality but with lots of efforts. To handle this situation we need to use SPGridView control which can give the sorting functionality same as sharepoint list view.

This webpart is generic webpart which you can use for any list. Just add webpart on the page and configure it and its ready to list items with sortable columns those you have configured. Exciting….isn’t it?

This webpart is very flexible to work, it can be used through out the site collection, not limited to just inside the site.

Only three steps to make this webpart up and running.

1. SiteName: URL of site (“/” for root site)

2.ListID: GUID of list

3.Fields: list your all the fields those you want to show on listing. Use “,” to separate the fields

Snap 2013-12-04 at 16.56.35

Your page is listing the items from defined list and site.

You can download code from here.

Enjoy!