RadGrid for ASP.NET

Overview Send comments on this topic.
See Also
Insert/Update/Delete records > CommandItem > Overview

Glossary Item Box

The CommandItem is a placeholder for commands that can perform some action on the selected/all items. See the Command reference topic for details about the available commands.

The [Add new record] and [Refresh] buttons will be automatically placed in a command item (GridCommandItem).

The CommandItem is available  as a property (CommandItemDisplay) of  the MasterTableView tag of RadGrid.

To enable the CommandItem, you need to use the CommandItemDisplay property of the MasterTableView of RadGrid, choosing an appropriate position for the command item-(Top / Bottom / TopAndBottom / None).

<_o3a_p> 

Basically, there are two groups of properties, pertaining to the Command Item. One of them is set in the tag of the MasterTableView, and the other one, as properties for the RadGrid control. Additionally, there is a group of style settings, which can be set through the CommandItemStyle tag of the RadGrid control (and which are also available as properties of RadGrid, and the MasterTableView). This is demonstrated in the code snippet below:

ASPX/ASCX Copy Code
<CommandItemStyleBackColor="#FFC0C0" BorderColor="#FFE0C0" BorderStyle="Dotted"
BorderWidth="1px"Font-Bold="True" Font-Italic="True" Font-Names="Arial Black"
Font-Overline="True"Font-Size="Small" Font-Strikeout="True" Font-Underline="True"
ForeColor="#404040"Height="40px" HorizontalAlign="Left" VerticalAlign="Middle"
Width="800px"Wrap="True" />

The same settings are available as properties of the grid control:

ASPX/ASCX Copy Code
<rad:RadGrid
CommandItemStyle-
BackColor="lightblue"
CommandItemStyle-Font-Bold="true"

The style settings can also be set through the MasterTableView declaration:

ASPX/ASCX Copy Code
<rad:RadGrid         
        
ID="RadGrid1" runat="server"
        
AllowSorting="True" DataSourceID="AccessDataSource1"
           
GridLines="None">         
           
<MasterTableView
            
CommandItemDisplay="Top"
            
CommandItemStyle-BackColor="lightblue"
            
CommandItemStyle-Font-Bold="true"   
           …

There is one additional tag, which includes settings for the commendItem’s image paths and button text:

ASPX/ASCX Copy Code
<MasterTableView
CommandItemDisplay="Top"            
AutoGenerateColumns="False" DataKeyNames="CustomerID"  DataSourceID="AccessDataSource1">                              
<CommandItemSettingsAddNewRecordImageUrl="Image1.jpg"
AddNewRecordText="AddNewRecordCustomText"
RefreshImageUrl="Image2.jpg"
RefreshText="RefreshCustomtext"/>                
</MasterTableView>   

These settings can also be included directly as settings of the MasterTableView declaration of RadGrid:

ASPX/ASCX Copy Code
<MasterTableView
CommandItemSettings-
AddNewRecordImageUrl="Image1.jpg"
CommandItemSettings-AddNewRecordText="AddNewRecordCustomText"
CommandItemSettings-RefreshImageUrl="Image2.jpg"
CommandItemSettings-RefreshText="RefreshCustomtext"
CommandItemDisplay="Top"               
AutoGenerateColumns="False"
DataKeyNames="CustomerID"
DataSourceID="AccessDataSource1">  

The RadGrid.ItemCommand event will be fired when a custom command bubbles from the CommandItem, which lets you define any functionality you can think of. A great benefit is that all the buttons residing in the CommandItem, will automatically take advantage of the RadGrid AJAX mechanism, without writing any extra code.

 

See Also