This documentation is archived and is not being maintained.

ButtonColumn Class

A column type for the DataGrid control that contains a user-defined command button, such as Add or Remove, that corresponds with each row in the column.

For a list of all members of this type, see ButtonColumn Members.


[Visual Basic]
Public Class ButtonColumn
   Inherits DataGridColumn
public class ButtonColumn : DataGridColumn
public __gc class ButtonColumn : public DataGridColumn
public class ButtonColumn extends DataGridColumn

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.


Use the ButtonColumn column type in a DataGrid control to create a command button that corresponds with each row in the DataGrid control. Specify the caption displayed in the command buttons by setting the Text property.

Note   If you set the Text property, all command buttons in the column share the same caption.

Alternatively, you can bind the ButtonColumn column to a field in a data source. This allows you to display different captions for the command buttons in the column. The values in the specified field are used for the text caption. Set the DataTextField property to bind the column to a field in a data source.

You can format the captions displayed in the command buttons by setting the DataTextField property with a formatting string.

Clicking on the command buttons in the column raises the ItemCommand event. You can programmatically control the action performed when the command button is clicked by providing an event handler for the ItemCommand event.

Note   Unlike regular button controls, validation in not performed when the buttons in the ButtonColumn are clicked. To create a column with buttons that perform validation when clicked, add a button control, such as Button or LinkButton, to a TemplateColumn.


Namespace: System.Web.UI.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web (in System.Web.dll)

See Also

ButtonColumn Members | System.Web.UI.WebControls Namespace | DataGrid | DataGridColumn | BoundColumn | EditCommandColumn | HyperLinkColumn | TemplateColumn | Button | LinkButton