AutoGeneratedFieldProperties Class
Assembly: System.Web (in system.web.dll)
The AutoGeneratedFieldProperties class is used by data-bound controls to specify the properties of an AutoGeneratedField object when creating an automatically generated field. For example, when the DetailsView control creates an automatically generated row, it creates an AutoGeneratedFieldProperties object with the row's properties and passes it to the CreateAutoGeneratedRow method. Likewise, the GridView control passes an AutoGeneratedFieldProperties object to the CreateAutoGeneratedColumn method when creating an automatically generated column.
Note: |
|---|
| This class is typically used only when extending the GridView or DetailsView control. |
You can specify the name of the field to bind to an AutoGeneratedField object by setting the DataField property. To specify the data type of the field values, set the Type property. You can prevent users from modifying the field values by setting the IsReadOnly property to true. You can also assign a name to an AutoGeneratedField object by setting the Name property.
The following code example demonstrates how to use the AutoGeneratedFieldProperties class to create an AutoGeneratedField object in a custom control that derives from the DetailsView control.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; using System.Security.Permissions; using System.Web; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class SimpleCustomControl : DetailsView { protected override AutoGeneratedField CreateAutoGeneratedRow(AutoGeneratedFieldProperties fieldProperties) { // Create an AutoGeneratedField object. AutoGeneratedField field = new AutoGeneratedField(fieldProperties.DataField); // Set the properties of the AutoGeneratedField using // the values from the AutoGeneratedFieldProperties // object contained in the fieldProperties parameter. ((IStateManager)field).TrackViewState(); field.HeaderText = fieldProperties.Name; field.SortExpression = fieldProperties.Name; field.ReadOnly = fieldProperties.IsReadOnly; field.DataType = fieldProperties.Type; return field; } } }
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
Note: