System.Web.UI.WebControls.ButtonColumn Class

A column type for the System.Web.UI.WebControls.DataGrid control that contains a user-defined button.

See Also: ButtonColumn Members


public class ButtonColumn : DataGridColumn


Use the System.Web.UI.WebControls.ButtonColumn class in a System.Web.UI.WebControls.DataGrid control to create a button that corresponds with each row in the System.Web.UI.WebControls.DataGrid control. Specify the caption that is displayed in the buttons by setting the ButtonColumn.Text property. If you set the ButtonColumn.Text property, all buttons in the System.Web.UI.WebControls.ButtonColumn object share the same caption. Alternatively, you can bind the System.Web.UI.WebControls.ButtonColumn buttons to a field in a data source. This allows you to display different captions for each button. The values in the specified field are used for the text caption. Set the ButtonColumn.DataTextField property to bind the System.Web.UI.WebControls.ButtonColumn to a field in a data source.

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

Clicking the buttons in the System.Web.UI.WebControls.ButtonColumn raises the DataGrid.ItemCommand event. You can programmatically control the action that is performed when the button is clicked by providing an event handler for the DataGrid.ItemCommand event.

By default, page validation is not performed when a button in the System.Web.UI.WebControls.ButtonColumn is clicked. Page validation determines whether the input controls that are associated with a validation control on the page all pass the validation rules that are specified by the validation control. To perform page validation when a button is clicked, set the ButtonColumn.CausesValidation property to true.


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,