AutoGeneratedFieldProperties.Name 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 AutoGeneratedField 物件的名稱。
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
屬性值
AutoGeneratedField 物件的名稱。 預設為空字串 (""),表示這個屬性未設定。
範例
下列程式碼範例示範如何使用 Name 屬性來判斷用來設定 HeaderText 物件的 屬性 AutoGeneratedField 的值。
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
備註
Name使用 屬性來指定物件的名稱 AutoGeneratedField 。 名稱通常是系結至 AutoGeneratedField 物件的功能變數名稱。 這個屬性的值也會顯示在 或 GridView 控制項中 DetailsView 物件的標頭區段中 AutoGeneratedField 。