Represents a grid view that looks and behaves like a SharePoint Foundation list view.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class SPGridView : GridView, ICallbackEventHandler, IPostBackEventHandler
The control supports the cascading style sheets that are built intoMicrosoft SharePoint Foundation 2010. You can present data in a grid view that closely resembles the view that SharePoint Foundation 2010 uses to display data from lists. You can also sort and group rows.
This class does not support auto-generated columns. This means that you must explicitly bind each column using SPBoundField.
One way to populate the control is to create an ADO.NET DataTable. You can then bind DefaultView to DataSource(), and then call DataBind(). You can do this by creating an ADO.NET DataTable or by using a query object, such as an SPSiteDataQuery object, that returns an ADO.NET DataTable. Additionally, you can use any ASP.NET data source control such as SPDataSource.
The following code shows how to set the values for this control.
<SharePoint:SPGridView runat="server" ID="grdPropertyValues" AutoGenerateColumns="false" RowStyle-BackColor="#DDDDDD" AlternatingRowStyle-BackColor="#EEEEEE" />