asp.net.ph

ButtonField.DataTextField Property

System.Web.UI.WebControls Namespace   ButtonField Class


.NET Framework version 2.0

Sets or retrieves the field from a data source to bind to the text caption of the buttons in a ButtonField.

Syntax


Inline <asp:buttonfield datatextfield = strFieldName ... >
Script ButtonField.DataTextField = strFieldName

Property Value


strFieldName String specifying the name of a field from the data source to bind to the text caption of the buttons in a ButtonField.

The property is read/write with no default value.

Remarks

Use the DataTextField property to specify or determine the field name from a data source to bind to the text caption of each button in a ButtonField control.

When this property is set, the caption for each button in the column is set to the corresponding row value in the specified field from the data source bound to the parent control. This allows setting a different text caption for each button in the column. To specify the same caption for all buttons, set the Text property instead.

NOTE: The DataTextField and Text properties cannot both be set at the same time. If both properties are set, the DataTextField property takes precedence.

When using data binding, you can specify a custom display format for the button captions by setting the DataTextFormatString property.

Example

The following example demonstrates how to set the DataTextField property to dynamically display different text captions in a ButtonField at run time.

<asp:buttonfield headertext = "Invoice"
   datatextfield = "OrderID" 
   commandname = "Select" />
Master~Details Using GridViews
Run Sample | View Source
See Also

ButtonField Members   Adding Button Fields to a GridView Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph