Represents a grid view that looks and behaves like a tree view.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)] [AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class SPGridView : GridView, ICallbackEventHandler, IPostBackEventHandler
SPGridView supports the Cascading Style Sheets built into WSS. You can present data in a grid view that closely resembles the view that SharePoint uses to display data from lists. You can also sort and group rows.
This class does not support auto-generated columns. That means you must explicitly bind each column using SPBoundField. You can do this by creating an ADO.NET DataTable or by using a query object that return an ADO.NET DataTable object, such as an SPSiteDataQuery object.
Note Make sure to set AutoGenerateColumns=false. If you set AutoGenerateColumns=true an exception will be thrown.
One way to populate the SPGridView control is to create an ADO.NET DataTable. You can bind the DefaultView property of a DataTable to the DataSource property of the SPGridView control, and then call the DataBind method.