AutoGeneratedFieldProperties Class

 

Represents the properties of an AutoGeneratedField object. This class cannot be inherited.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

System.Object
  System.Web.UI.WebControls.AutoGeneratedFieldProperties

public sealed class AutoGeneratedFieldProperties : IStateManager

NameDescription
System_CAPS_pubmethodAutoGeneratedFieldProperties()

Initializes a new instance of the AutoGeneratedFieldProperties class.

NameDescription
System_CAPS_pubpropertyDataField

Gets or sets the name of the field bound to the AutoGeneratedField object.

System_CAPS_pubpropertyIsReadOnly

Gets or sets a value indicating whether the values displayed in an AutoGeneratedField object can be modified in edit mode.

System_CAPS_pubpropertyName

Gets or sets the name of the AutoGeneratedField object.

System_CAPS_pubpropertyType

Gets or sets the data type of the value displayed in an AutoGeneratedFieldProperties object.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.LoadViewState(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Loads the previously saved view state of the AutoGeneratedFieldProperties object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.SaveViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Saves the current view state of the AutoGeneratedFieldProperties object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.TrackViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Marks the starting point at which to begin tracking and saving view-state changes to the AutoGeneratedFieldProperties object.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIStateManager.IsTrackingViewState

This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether the AutoGeneratedFieldProperties object is tracking its view-state changes.

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.

System_CAPS_noteNote

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;
        }

    }
}

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: