Controls You Can Use on Web Forms ASP.NET Data Controls GridView Control
A BoundField in a GridView control enables authors to specify which of the fields from the data source will display and in what order, as well as to customize information such as the column’s header text and data display format.
- Set the GridView control’s AutoGenerateColumns property to false.
<asp:GridView id="myGrid" runat="server"
autogeneratecolumns=false
...
>
- Within the GridView declaration, declare a <Columns> element.
- Within the Columns element, define each of the <
asp:BoundField > controls you intend to display, specifying at the very least the required DataField property for each column.
- Optionally set the BoundField control’s other properties, such as the HeaderText and DataFormatString. For syntax, see GridView Control Syntax.
<columns>
<asp:boundfield headertext="Type"
datafield="ProductType" />
...
<asp:boundfield headertext="Price"
datafield="UnitPrice"
htmlencode=false
dataformatstring="{0:c}"
itemstyle-horizontalalign="right" />
</columns>
For additional information, see BoundField in the class library.
Adding Button Fields to a GridView Control Adding Hyperlink Fields to a GridView Control Adding Template Fields to a GridView Control
|