AutoGeneratedFieldProperties Class (System.Web.UI.WebControls)

Switch View :
ScriptFree
.NET Framework Class Library
AutoGeneratedFieldProperties Class

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

Inheritance Hierarchy

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

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

Visual Basic
Public NotInheritable Class AutoGeneratedFieldProperties _
	Implements IStateManager
C#
public sealed class AutoGeneratedFieldProperties : IStateManager
Visual C++
public ref class AutoGeneratedFieldProperties sealed : IStateManager
F#
[<Sealed>]
type AutoGeneratedFieldProperties =  
    class
        interface IStateManager
    end

The AutoGeneratedFieldProperties type exposes the following members.

Constructors

  Name Description
Public method AutoGeneratedFieldProperties Initializes a new instance of the AutoGeneratedFieldProperties class.
Top
Properties

  Name Description
Public property DataField Gets or sets the name of the field bound to the AutoGeneratedField object.
Public property IsReadOnly Gets or sets a value indicating whether the values displayed in an AutoGeneratedField object can be modified in edit mode.
Public property Name Gets or sets the name of the AutoGeneratedField object.
Public property Type Gets or sets the data type of the value displayed in an AutoGeneratedFieldProperties object.
Top
Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations

  Name Description
Explicit interface implemetation Private property IStateManager.IsTrackingViewState Infrastructure. Gets a value indicating whether the AutoGeneratedFieldProperties object is tracking its view-state changes.
Explicit interface implemetation Private method IStateManager.LoadViewState Infrastructure. Loads the previously saved view state of the AutoGeneratedFieldProperties object.
Explicit interface implemetation Private method IStateManager.SaveViewState Infrastructure. Saves the current view state of the AutoGeneratedFieldProperties object.
Explicit interface implemetation Private method IStateManager.TrackViewState Infrastructure. Marks the starting point at which to begin tracking and saving view-state changes to the AutoGeneratedFieldProperties object.
Top
Remarks

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 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.

Examples

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.

Visual Basic


Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions
Imports System.Web

Namespace Samples.AspNet.VB.Controls

    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> Public Class SimpleCustomControl
        Inherits System.Web.UI.WebControls.DetailsView

        Protected Overrides Function CreateAutoGeneratedRow(ByVal fieldProperties As AutoGeneratedFieldProperties) As AutoGeneratedField

            ' Create an AutoGeneratedField object.
            Dim field As New AutoGeneratedField(fieldProperties.DataField)

            ' Set the properties of the AutoGeneratedField using
            ' the values from the AutoGeneratedFieldProperties 
            ' object contained in the fieldProperties parameter.
            CType(field, IStateManager).TrackViewState()
            field.HeaderText = fieldProperties.Name
            field.SortExpression = fieldProperties.Name
            field.ReadOnly = fieldProperties.IsReadOnly
            field.DataType = fieldProperties.Type

            Return field

        End Function

    End Class

End Namespace



C#


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

    }
}



Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Thread Safety

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

Reference

AutoGeneratedFieldProperties