System.Web.UI.WebControls Namespace DataGrid Class
Sets or retrieves a value specifying whether BoundColumn objects are automatically created and displayed in the DataGrid control for each field in the data source.
Inline |
<asp:datagrid autogeneratecolumns = true | false ... > |
Script |
DataGrid.AutoGenerateColumns [ = true | false ] |
This property accepts or returns only a boolean value: true if BoundColumn objects are automatically created and displayed; otherwise, false. Default value is true.
Use this property to automatically create a BoundColumn object for each field in the data source. Each field is then rendered as a column in the DataGrid control in the order that the fields appear in the data source.
NOTE: Explicitly declared columns may be used in conjunction with auto-generated columns. When using both, explicitly declared columns will be rendered first, followed by the auto-generated columns. Auto-generated columns are not added to the Columns collection.
The following example demonstrates how to disable the AutoGenerateColumns property to enable using other column types for each specified field in the data source.
<asp:datagrid id = "myGrid" runat = "server" ...
autogeneratecolumns=false>
<columns>
<asp:boundcolumn headertext = "Brand"
datafield = "Brand" />
...
<asp:templatecolumn>
...
</asp:templatecolumn>
</columns>
</asp:datagrid>
Show me
DataGrid Members BoundColumn ButtonColumn EditCommandColumn HyperLinkColumn TemplateColumn