asp.net.ph

DataGrid.AutoGenerateColumns Property

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.

Syntax


Inline <asp:datagrid autogeneratecolumns = true | false ... >
Script DataGrid.AutoGenerateColumns [ = true | false ]

Property Value

This property accepts or returns only a boolean value: true if BoundColumn objects are automatically created and displayed; otherwise, false. Default value is true.

Remarks

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.

Example

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 

See Also

DataGrid Members   BoundColumn   ButtonColumn   EditCommandColumn   HyperLinkColumn   TemplateColumn 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