AutoGeneratedFieldProperties.Name Propriedade

Definição

Obtém ou define o nome do objeto AutoGeneratedField.Gets or sets the name of the AutoGeneratedField object.

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

Valor da propriedade

String

O nome do objeto AutoGeneratedField.The name of the AutoGeneratedField object. O padrão é uma cadeia de caracteres vazia (""), que indica que essa propriedade não está definida.The default is an empty string (""), which indicates that this property is not set.

Exemplos

O exemplo de código a seguir demonstra como usar a Name propriedade para determinar o valor com o qual definir a HeaderText propriedade de um AutoGeneratedField objeto.The following code example demonstrates how to use the Name property to determine the value with which to set the HeaderText property of an AutoGeneratedField object.


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


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

Comentários

Use a Name propriedade para especificar o nome do AutoGeneratedField objeto.Use the Name property to specify the name of the AutoGeneratedField object. O nome é geralmente o nome do campo associado ao AutoGeneratedField objeto.The name is often the name of the field bound to the AutoGeneratedField object. O valor dessa propriedade também é exibido na seção de cabeçalho do AutoGeneratedField objeto em um DetailsView GridView controle ou.The value of this property is also displayed in the header section of the AutoGeneratedField object in a DetailsView or a GridView control.

Aplica-se a

Confira também