AutoGeneratedField 類別

定義

代表資料繫結控制項中自動產生的欄位。 此類別無法獲得繼承。

public ref class AutoGeneratedField sealed : System::Web::UI::WebControls::BoundField
public sealed class AutoGeneratedField : System.Web.UI.WebControls.BoundField
type AutoGeneratedField = class
    inherit BoundField
Public NotInheritable Class AutoGeneratedField
Inherits BoundField
繼承
AutoGeneratedField

範例

下列範例示範如何為衍生自 控制項的 DetailsView 自訂控制項建立 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

備註

類別 AutoGeneratedField 是用來表示資料繫結控制項中自動產生的欄位,例如 GridViewDetailsView 。 當適當的屬性設定為 true (、控制項的 屬性、 AutoGenerateRows 控制項的 屬性 GridView DetailsView) 等等時, AutoGenerateColumns 會自動產生的欄位是由資料繫結控制項所建立。

注意

自動產生的欄位不會新增至資料繫結控制項的欄位集合 (,例如控制項 Columns 的集合、 Fields 控制項的 DetailsView 集合 GridView 等等) 。

類別 AutoGeneratedField 適用于資料繫結控制項在內部使用。 不同于其他資料欄位 (例如 BoundFieldCheckBoxFieldTemplateField 等等) , AutoGeneratedField 類別不能以宣告方式放置在頁面上做為欄位集合的一部分。 雖然您可以以程式設計方式將物件新增 AutoGeneratedField 至欄位集合,但應該避免此設計模式。

由於自動產生的欄位代表欄位的自動轉譯,因此資料繫結控制項通常不允許使用者修改物件的屬性 AutoGeneratedField 。 如果自動轉譯不適合您的需求,請為控制項的欄位集合定義您自己的資料欄位。

建構函式

AutoGeneratedField(String)

使用指定的資料欄位,初始化 AutoGeneratedField 類別的新執行個體。

屬性

AccessibleHeaderText

取得或設定在部分控制項中呈現為 AbbreviatedText 屬性值的文字。

(繼承來源 DataControlField)
ApplyFormatInEditMode

取得或設定值,表示當包含 DataFormatString 物件的資料繫結控制項處於編輯模式時,是否將 BoundField 屬性指定的格式字串套用至欄位值。

(繼承來源 BoundField)
Control

取得與 DataControlField 物件關聯之資料控制項的參考。

(繼承來源 DataControlField)
ControlStyle

取得 DataControlField 物件內含之任何 Web 伺服器控制項的樣式。

(繼承來源 DataControlField)
ConvertEmptyStringToNull

取得或設定值,指出從資料來源擷取欄位值時,是否將空字串 ("") 值轉換成 null

DataField

取得或設定要繫結至 BoundField 物件之資料欄位的名稱。

(繼承來源 BoundField)
DataFormatString

取得或設定字串,指定 AutoGeneratedField 物件中每個影像之替代文字的呈現格式。

DataType

取得或設定 AutoGeneratedField 物件中顯示之值的資料類型。

DesignMode

取得值,指示目前是否在設計階段環境中檢視資料控制項欄位。

(繼承來源 DataControlField)
FooterStyle

取得或設定資料控制項欄位的頁尾樣式。

(繼承來源 DataControlField)
FooterText

取得或設定顯示在資料控制項欄位之頁尾項目中的文字。

(繼承來源 DataControlField)
HeaderImageUrl

取得或設定顯示在資料控制項欄位的標頭項目中之影像的 URL。

(繼承來源 DataControlField)
HeaderStyle

取得或設定資料控制項欄位的標頭樣式。

(繼承來源 DataControlField)
HeaderText

取得或設定顯示在資料控制項標頭中的文字。

(繼承來源 BoundField)
HtmlEncode

取得或設定值,表示在 BoundField 物件中顯示欄位值之前,是否對其進行 HTML 編碼。

(繼承來源 BoundField)
HtmlEncodeFormatString

取得或設定值,這個值表示透過將 DataFormatString 屬性套用至 BoundField 值來建立的文字在顯示時,是否應該經過 HTML 編碼。

(繼承來源 BoundField)
InsertVisible

取得或設定值,指出 AutoGeneratedField 物件在插入模式中是否可見。

IsTrackingViewState

取得值,指出 DataControlField 物件是否正在將變更儲存到它的檢視狀態。

(繼承來源 DataControlField)
ItemStyle

取得由資料控制項欄位顯示之任何文字基礎內容的樣式。

(繼承來源 DataControlField)
NullDisplayText

取得或設定欄位值為 null 時所顯示的欄位標題。

(繼承來源 BoundField)
ReadOnly

取得或設定值,表示是否可以在編輯模式下修改欄位值。

(繼承來源 BoundField)
ShowHeader

取得或設定值,指示是否呈現資料控制項欄位的標頭項目。

(繼承來源 DataControlField)
SortExpression

取得或設定資料來源控制項用於排序資料的排序運算式。

(繼承來源 DataControlField)
SupportsHtmlEncode

取得值,表示 BoundField 物件是否支援 HTML 編碼。

(繼承來源 BoundField)
ValidateRequestMode

取得或設定值,決定控制項是否驗證用戶端輸入。

(繼承來源 BoundField)
ViewState

取得狀態資訊的字典,允許您在相同頁面的多個要求之間,儲存和還原 DataControlField 物件的檢視狀態。

(繼承來源 DataControlField)
Visible

取得或設定值,指示是否呈現資料控制項欄位。

(繼承來源 DataControlField)

方法

CloneField()

建立目前 DataControlField 衍生物件的複本。

(繼承來源 DataControlField)
CopyProperties(DataControlField)

將目前 BoundField 物件的屬性複製到指定的 DataControlField 物件。

(繼承來源 BoundField)
CreateField()

建立空的 BoundField 物件。

(繼承來源 BoundField)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean)

使用指定 IOrderedDictionary 物件的值填入指定的 DataControlFieldCell 物件。

FormatDataValue(Object, Boolean)

格式化 BoundField 物件中儲存格的指定欄位值。

(繼承來源 BoundField)
GetDesignTimeValue()

在設計工具中呈現 BoundField 物件時,擷取欄位值所使用的值。

(繼承來源 BoundField)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetValue(Control)

擷取繫結至 BoundField 物件之欄位的值。

(繼承來源 BoundField)
Initialize(Boolean, Control)

初始化 BoundField 物件。

(繼承來源 BoundField)
InitializeCell(DataControlFieldCell, DataControlCellType, DataControlRowState, Int32)

初始化指定的 TableCell 物件為指定的資料列狀態。

(繼承來源 BoundField)
InitializeDataCell(DataControlFieldCell, DataControlRowState)

初始化指定的 TableCell 物件為指定的資料列狀態。

(繼承來源 BoundField)
LoadViewState(Object)

還原這個欄位之前儲存的檢視狀態資訊。

(繼承來源 BoundField)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnDataBindField(Object, EventArgs)

將欄位值繫結至 BoundField 物件。

(繼承來源 BoundField)
OnFieldChanged()

引發 FieldChanged 事件。

(繼承來源 DataControlField)
SaveViewState()

儲存自頁面回傳至伺服器以來對 DataControlField 檢視狀態所做的變更。

(繼承來源 DataControlField)
ToString()

傳回字串,表示這個 DataControlField 物件。

(繼承來源 DataControlField)
TrackViewState()

會造成 DataControlField 物件追蹤其檢視狀態變更,以將這些變更儲存在控制項的 ViewState 屬性中,並持續存取相同頁面的其他要求。

(繼承來源 DataControlField)
ValidateSupportsCallback()

決定 AutoGeneratedField 物件中包含的控制項是否支援回呼。

明確介面實作

IDataSourceViewSchemaAccessor.DataSourceViewSchema

取得或設定與此 DataControlField 物件相關聯的結構描述。

(繼承來源 DataControlField)
IStateManager.IsTrackingViewState

取得值,指出 DataControlField 物件是否正在將變更儲存到它的檢視狀態。

(繼承來源 DataControlField)
IStateManager.LoadViewState(Object)

將資料控制項欄位還原成先前儲存的檢視狀態。

(繼承來源 DataControlField)
IStateManager.SaveViewState()

儲存自頁面回傳至伺服器以來對 DataControlField 檢視狀態所做的變更。

(繼承來源 DataControlField)
IStateManager.TrackViewState()

會造成 DataControlField 物件追蹤其檢視狀態變更,以將這些變更儲存在控制項的 ViewState 屬性中,並持續存取相同頁面的其他要求。

(繼承來源 DataControlField)

適用於

另請參閱