asp.net.ph

DetailsView.AutoGenerateRows Property

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.

Syntax


Inline <asp:detailsview autogeneraterows = true | false ... >
Script DetailsView.AutoGenerateRows [ = true | false ]

Property Value

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

Remarks

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.

Example

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.

DetailsView with Default Paging
Run Sample | View Source
Adding Sort Functionality to the DetailsView Control
Run Sample | View Source
DetailsView AlternatingRowStyle Example
Run Sample | View Source

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 ImageField Example
Run Sample | View Source
See Also

DetailsView Members   BoundField   ButtonField   CheckBoxField   CommandField   HyperLinkField   ImageField   TemplateField 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