asp.net.ph

BoundColumn.DataField Property

System.Web.UI.WebControls Namespace   BoundColumn Class


Sets or retrieves the field from the data source to bind to the column.

Syntax


Inline <asp:boundcolumn datafield = strFieldName ... >
Script BoundColumn.DataField = strFieldName

Property Value


strFieldName String specifying the name of a field to bind to the column.

The property is read/write with no default value.

Remarks

Use the DataField property to specify the field name from a data source to bind to the column.

You can specify a custom display format for the field values by setting the DataFormatString property.

Example

The following example demonstrates how to set the DataField property at design time, to specify the names of the fields in the data source to bind to the columns of a DataGrid.

<asp:datagrid id = "myGrid" runat = "server" ... 
   autogeneratecolumns=false>

   <columns>
      <asp:boundcolumn headertext = "Type"
         datafield = "ProductType" />
      <asp:boundcolumn headertext = "Brand/Model"
         datafield = "ProductName" />
      <asp:boundcolumn headertext = "Description"
         datafield = "ProductDescription" />
      <asp:boundcolumn headertext = "Price"
         datafield = "UnitPrice"
         dataformatstring = "{0:c}"
         itemstyle-horizontalalign = "right" />
   </columns>

</asp:datagrid>

 Show me 

See Also

BoundColumn Members   Adding Bound Columns to a DataGrid 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