Edit this page

Server-Side Programming Overview

Classes and Properties

Following is a table of the most important properties you should be aware of when working with RadGrid.

Property Description
RadGrid.MasterTableView The main grid table - in the general case, when there is no hierarchy, only RadGrid.MasterTableView is rendered. You can think of this table as if it is the grid itself. MasterTableView and generally all table-views in the hierarchy use the style, client behavior and other settings applied to RadGrid , unless explicitly specified otherwise.
GridTableView.DetailTables This collection is used for defining the hierarchical structure of RadGrid .
RadGrid.ClientSettings Set various client-side appearance and behavior options. See RadGridTable client-side API for details.
RadGrid.*Style Properties that control the visual appearance of RadGrid and all tables in the hierarchy.
GridDataTable.*Style properties Properties that control the visual appearance of GridDataTable and all tables in the hierarchy.
GridTableView.ColumnGroups A collection of type GridColumnGroupCollection which holds the multiheaders in the GridTableView
GridTableView.GroupByExpressions Add or remove objects to this collection to set grouping programmatically.
GridTableView.SortExpressions Add or remove objects to this collection to set sorting programmatically.
GridTableView.Columns , GridTableView.AutoGeneratedColumns , GridTableView.RenderColumns Properties to access runtime columns. Columns are set by default in design mode. AutoGeneratedColumns - are automatically generated columns RenderColumns - all columns - columns+ AutoGenerated (if any) + structure columns - expand/collapse and group-splitters
note

Instead of setting properties for each GridTableView, you can use RadGrid global properties for: PageSize, AllowSorting, AllowPaging, AllowCustomPaging, ShowFooter, ShowHeader, BackColor, BorderColor, PagerStyle. Thus they will be set for each table in the hierarchy, unless specified otherwise.

Events

When working with Telerik RadGrid you will probably often use the following events:

Category Event Description
Action CancelCommand Fired when the Cancel button is clicked for an item in the RadGrid control.
DeleteCommand Fired when the Delete button is clicked for an item in the RadGrid control.
EditCommand Fired when the Edit button is clicked for an item in the RadGrid control.
UpdateCommand Fired when the Update button is clicked for an item in the RadGrid control.
InsertCommand Fired when the Insert button is clicked for an item in the RadGrid control.
ItemCommand Fired when any button is clicked in the RadGrid control. All bubbled events from grid items fire RadGrid.ItemCommand . Those like - Edit, Delete, or Update command events can be used to handle custom data-editing in RadGrid. Expand/Collapse items in the hierarchy or GridGroupHeaderItem -s (if grid displays grouped items), also fired after binding of detail tables, etc.
SortCommand Fired when a column is sorted. To determine the new/previous sort order on sort command, check the values for the e.NewSortOrder and e.OldSortOrder arguments.
PageIndexChanged Fired when one of the page selection elements is clicked.
PageSizeChanged Fired when the page size is changed through the advanced pager or manually in code
SelectedIndexChanged (inherited from GridBaseDataList ) Fired when a different item is selected in a data listing control between posts to the server.
NeedDataSource Fired when RadGrid needs a data source for rebinding.
GroupsChanging Fired when Telerik RadGrid tries to group its data (e.g. when a column header is dragged to the Group Panel).
Behavior ItemCreated Fired on the server when an item in the RadGrid control is created.
ItemDataBound Fired after an item is databound to the RadGrid control.
ItemEvent Marked for internal usage.
ColumnCreated This event is fired after the creation of auto-generated columns.
ColumnCreating Fires before a custom column is created. You can handle the event to replace or modify the instance of the column that should be created and added into the collection of column in the corresponding GridTableView .
CreateColumnEditor Fired -after- the NeedDataSource event of the grid (which is raised right after the PageLoad event) and -before- any postback events for controls on the page/user control.
ColumnsReorder Fired when column reorder occurs (only when ClientSettings -> ReorderColumnsOnClient is set to false!)
Data DataBinding (inherited from Control ) Fired right before the server control binds to a data source. This event will fire only once, when RadGrid is initially binding.
DataBound (inherited from Control ) Fired when the server control is bound to a data source.
DetailTableDataBind Fired when a table from DetailTablesCollection binds to a data source.
Automatic data editing operations ** ItemDeleted ** Fired when an automatic delete operation is executed.
** ItemUpdated ** Fired when an automatic update operation is executed.
** ItemInserted ** Fired when an automatic insert operation is executed.
Row drag/drop ** RowDrop ** Fired when drag and drop operation is triggered from the client
Export OnGridExporting Fired when RadGrid is exported to Excel/Word/Csv/Pdf before the resulting document is rendered on the client.
OnPdfExporting Fired when RadGrid is exported to Pdf before the resulting document is rendered on the client. Appropriate for customizing the grid table appearance in the .pdf document.
OnExcelExportCellFormatting Fired when RadGrid is exported to Excel before the resulting document is rendered on the client.
OnExcelMLExportStylesCreated Fired when RadGrid is exported to native Excel before the OnExcelMLExportRowCreated event.
OnExcelMLExportRowCreated Fired when RadGrid is exported to native Excel before the resulting document is rendered on the client.
Misc Disposed (inherited from Control ) Fired when a server control is released from the memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.
Init (inherited from Control ) Fired when the server control is initialized, which is the first step in its lifecycle.
Load (inherited from Control ) Fired when the server control is loaded into the RadGrid object.
PreRender (inherited from Control ) Fired when the server control is about to render to its containing Page object.
Unload (inherited from Control ) Fired when the server control is unloaded from the memory.
note

RadGrid ColumnCreating event is fired only for custom columns that inherit one of RadGrid's column types. Additionally, as this event is fired very early in RadGrid's lifecycle, it will not fire if the custom user-created column is placed declaratively in the .aspx page, as the markup is parsed at a later stage.
Another peculiarity to note, is that the ColumnCreating event will fire only after a postback. It will not fire on initial page load (IsPostBack = false). The explanation for this is that the event is designed to service any needs to restore custom column properties from the viewstate or other source. Where these column properties are initially set when defining the custom column, this is not the case when the page posts back and RadGrid needs to load its properties from the viewstate. This is where the ColumnCreating event comes in, giving the ability to manually restore custom properties for the column.