System.Web.UI.WebControls Namespace DetailsView Class
.NET Framework version 2.0
Sets or retrieves a value specifying whether BoundField objects are automatically created and displayed in the DetailsView control for each field in the data source.
Inline |
<asp:detailsview autogeneraterows = true | false ... > |
Script |
DetailsView.AutoGenerateRows [ = true | false ] |
This property accepts or returns only a boolean value: true if BoundField objects are automatically created and displayed; otherwise, false. Default value is true.
Use this property to automatically create a BoundField object for each field in the data source. Each field is then rendered as a column in the DetailsView 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 Rows collection.
The following examples illustrate using automatically generated BoundField objects for each field in the data source. Note that there really is no need to explicitly declare the AutoGenerateRows property, as it defaults to true if not specified.
The following example demonstrates how to disable the AutoGenerateRows property to enable using other column types for each specified field in the data source.
<asp:detailsview id = "myGrid" runat = "server" ... >
datasourceid = "plans"
autogeneratecolumns=false ... >
<columns>
<asp:imagefield dataimageurlfield = "PlanID"
dataimageurlformatstring = "~/shared/images/plans/thumbs/{0}.jpg"
dataalternatetextfield = "Model"
readonly = "true" />
<asp:templatefield>
<headertemplate>
Choose your dream home
</headertemplate>
<itemtemplate>
<asp:linkbutton runat = "server" commandname = "select"
text='<%# Eval ( "Model" ) %>' />
</itemtemplate>
</asp:templatefield>
<asp:boundfield headertext = "Avg. Cost To Build"
datafield = "Cost"
htmlencode=false
dataformatstring = "{0:c}"
rowstyle-horizontalalign = "right" />
</columns>
</asp:detailsview>
DetailsView Members BoundField ButtonField CheckBoxField CommandField HyperLinkField ImageField TemplateField