| ||||||||||||
GridView.AutoGenerateColumns PropertySystem.Web.UI.WebControls Namespace GridView Class .NET Framework version 2.0 Sets or retrieves a value specifying whether BoundField objects are automatically created and displayed in the GridView control for each field in the data source. Syntax
Property ValueThis property accepts or returns only a boolean value: true if BoundField objects are automatically created and displayed; otherwise, false. Default value is true. RemarksUse 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 GridView control in the order that the fields appear in the data source.
ExampleThe 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 AutoGenerateColumns property, as it defaults to true if not specified.
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:gridview 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:gridview>
See AlsoGridView Members BoundField ButtonField CheckBoxField CommandField HyperLinkField ImageField TemplateField |
| |||||||||||
Check out related books at Amazon
© 2000-2008 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 aspxtreme