SPGridView Class

Represents a grid view that looks and behaves like a tree view.

Inheritance Hierarchy


Namespace:  Microsoft.SharePoint.WebControls
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 _
    Inherits GridView _
    Implements ICallbackEventHandler, IPostBackEventHandler

Dim instance As SPGridView
[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, 


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.






AlternatingRowStyle-BackColor="#EEEEEE" />

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


SPGridView Members

Microsoft.SharePoint.WebControls Namespace