DynamicField Class
Collapse the table of content
Expand the table of content

DynamicField Class

 

Represents a data field that is displayed in a data-bound control that uses ASP.NET Dynamic Data features.

Namespace:   System.Web.DynamicData
Assembly:  System.Web.DynamicData (in System.Web.DynamicData.dll)

System.Object
  System.Web.UI.WebControls.DataControlField
    System.Web.DynamicData.DynamicField

public class DynamicField : DataControlField, IAttributeAccessor, 
	IFieldFormattingOptions

NameDescription
System_CAPS_pubmethodDynamicField()

Initializes a new instance of the DynamicField class.

NameDescription
System_CAPS_pubpropertyAccessibleHeaderText

Gets or sets text that is rendered as the AbbreviatedText property value in some controls.(Inherited from DataControlField.)

System_CAPS_pubpropertyApplyFormatInEditMode

Gets or sets a value that indicates whether the formatted string that is specified by the DataFormatString property is applied to field value when the data field is in edit mode.

System_CAPS_protpropertyColumn

Gets the MetaColumn object that this DynamicField object is associated with.

System_CAPS_protpropertyControl

Gets a reference to the data control that the DataControlField object is associated with.(Inherited from DataControlField.)

System_CAPS_pubpropertyControlStyle

Gets the style of any Web server controls contained by the DataControlField object.(Inherited from DataControlField.)

System_CAPS_pubpropertyConvertEmptyStringToNull

Gets or sets a value that indicates whether empty string values ("") are automatically converted to null values when the data field is updated in the data source.

System_CAPS_pubpropertyDataField

Gets or sets the name of the data field to bind the DynamicField object to.

System_CAPS_pubpropertyDataFormatString

Gets or sets the string that specifies the display format for the value of the data field.

System_CAPS_protpropertyDesignMode

Gets a value indicating whether a data control field is currently viewed in a design-time environment.(Inherited from DataControlField.)

System_CAPS_pubpropertyFooterStyle

Gets or sets the style of the footer of the data control field.(Inherited from DataControlField.)

System_CAPS_pubpropertyFooterText

Gets or sets the text that is displayed in the footer item of a data control field.(Inherited from DataControlField.)

System_CAPS_pubpropertyHeaderImageUrl

Gets or sets the URL of an image that is displayed in the header item of a data control field.(Inherited from DataControlField.)

System_CAPS_pubpropertyHeaderStyle

Gets or sets the style of the header of the data control field.(Inherited from DataControlField.)

System_CAPS_pubpropertyHeaderText

Gets or sets the text that is displayed in the header of the data-bound control that contains the DynamicField object.(Overrides DataControlField.HeaderText.)

System_CAPS_pubpropertyHtmlEncode

Gets or sets a value that indicates whether data field values are HTML-encoded before they are displayed in a DynamicField object.

System_CAPS_pubpropertyInsertVisible

Gets a value indicating whether the DataControlField object is visible when its parent data-bound control is in insert mode.(Inherited from DataControlField.)

System_CAPS_protpropertyIsTrackingViewState

Gets a value indicating whether the DataControlField object is saving changes to its view state.(Inherited from DataControlField.)

System_CAPS_pubpropertyItemStyle

Gets the style of any text-based content displayed by a data control field.(Inherited from DataControlField.)

System_CAPS_pubpropertyNullDisplayText

Gets or sets the caption that is displayed for a data field when the field value is null.

System_CAPS_pubpropertyReadOnly

Gets the read-only state of the dynamic field.

System_CAPS_pubpropertyShowHeader

Gets or sets a value indicating whether the header item of a data control field is rendered.(Inherited from DataControlField.)

System_CAPS_pubpropertySortExpression

Gets or sets the sort expression that is used when the data field is used to sort the data source by.(Overrides DataControlField.SortExpression.)

System_CAPS_pubpropertyUIHint

Gets or sets the field template to use for displaying the data field.

System_CAPS_pubpropertyValidateRequestMode

Gets or sets a value that specifies whether the control validates client input.

System_CAPS_pubpropertyValidationGroup

Gets the ValidationGroup object that this DynamicField object is associated with.

System_CAPS_protpropertyViewState

Gets a dictionary of state information that allows you to save and restore the view state of a DataControlField object across multiple requests for the same page.(Inherited from DataControlField.)

System_CAPS_pubpropertyVisible

Gets or sets a value indicating whether a data control field is rendered.(Inherited from DataControlField.)

NameDescription
System_CAPS_protmethodCloneField()

This API supports the product infrastructure and is not intended to be used directly from your code. Creates a duplicate copy of the current DataControlField-derived object.(Inherited from DataControlField.)

System_CAPS_protmethodConfigureDynamicControl(DynamicControl)

Provides a mechanism to modify a DynamicControl object that was created by the InitializeCell method.

System_CAPS_protmethodCopyProperties(DataControlField)

Copies the properties of the current DynamicField object to the specified DataControlField object.(Overrides DataControlField.CopyProperties(DataControlField).)

System_CAPS_protmethodCreateDynamicControl()

Provides a mechanism for classes that derive from DynamicField to override how a DynamicControl object is created.

System_CAPS_protmethodCreateField()

Creates and returns a new instance of the DynamicField class.(Overrides DataControlField.CreateField().)

System_CAPS_pubmethodEquals(Object)

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

System_CAPS_pubmethodExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean)

Extracts the value of the data field from the current table cell and adds the value to the specified dictionary.(Overrides DataControlField.ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean).)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetAttribute(String)

Retrieves the specified attribute value.

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_pubmethodInitialize(Boolean, Control)

Performs basic instance initialization for a data control field.(Inherited from DataControlField.)

System_CAPS_pubmethodInitializeCell(DataControlFieldCell, DataControlCellType, DataControlRowState, Int32)
System_CAPS_protmethodLoadViewState(Object)

Restores the data source view's previously saved view state.(Inherited from DataControlField.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnFieldChanged()

Raises the FieldChanged event.(Inherited from DataControlField.)

System_CAPS_protmethodSaveViewState()

Saves the changes made to the DataControlField view state since the time the page was posted back to the server.(Inherited from DataControlField.)

System_CAPS_pubmethodSetAttribute(String, String)

Sets an attribute that is associated with the DynamicField object.

System_CAPS_pubmethodToString()

Returns a string that represents this DataControlField object.(Inherited from DataControlField.)

System_CAPS_protmethodTrackViewState()

Causes the DataControlField object to track changes to its view state so they can be stored in the control's ViewState property and persisted across requests for the same page.(Inherited from DataControlField.)

System_CAPS_pubmethodValidateSupportsCallback()

When overridden in a derived class, signals that the controls contained by a field support callbacks.(Inherited from DataControlField.)

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. Restores the data control field's previously saved view state.(Inherited from DataControlField.)

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 changes made to the DataControlField view state since the time the page was posted back to the server.(Inherited from DataControlField.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.TrackViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Causes the DataControlField object to track changes to its view state so they can be stored in the control's ViewState property and persisted across requests for the same page.(Inherited from DataControlField.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDataSourceViewSchemaAccessor.DataSourceViewSchema

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the schema associated with this DataControlField object.(Inherited from DataControlField.)

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 DataControlField object is saving changes to its view state.(Inherited from DataControlField.)

NameDescription
System_CAPS_pubmethodConvertEditedValue(String)

Returns the value provided by a user for a control that is being validated.(Defined by DynamicDataExtensions.)

System_CAPS_pubmethodFormatEditValue(Object)

Formats the specified field value by using the specified formatting options.(Defined by DynamicDataExtensions.)

System_CAPS_pubmethodFormatValue(Object)

Formats the specified field value by using the specified formatting options.(Defined by DynamicDataExtensions.)

The DynamicField class is used by data-bound controls, such as the GridView and DetailsView controls, to display a field value that uses ASP.NET Dynamic Data features in custom pages.

The DynamicField class provides functionality that resembles that of the BoundField class. However, because a DynamicField object is used in Dynamic Data applications, you can take advantage of the following Dynamic Data features:

  • Automatically rendering the proper control for a field by using field templates, based on the data type. The field templates can be globally modified for the entire application.

  • Providing built-in data validation based on the database schema. You can also add validation types by customizing the data model.

  • Customizing data rendering for individual fields by using attributes in the data model or by using the UIHint property.

The DynamicField object renders each field by using a DynamicControl control. To specify the data field to display in a DynamicField object, set the DataField property to the field name. You can apply a custom formatting string to the field value by setting the DataFormatString property. By default the formatting string is applied to field values only when the data-bound control is in read-only mode. To apply the formatting string to values displayed while the data-bound control is in edit mode, set the ApplyFormatInEditMode property to true. If a field value is null, you can display a custom caption by setting the NullDisplayText property. The DynamicField object can also automatically convert empty string ("") field values to null values by setting the ConvertEmptyStringToNull property to true.

<asp:DynamicField 
    AccessibleHeaderText="string"     
    ApplyFormatInEditMode="true|false"  
    ControlStyle-BackColor="color name|#dddddd" 
    ControlStyle-BorderColor="color name|#dddddd" 
    ControlStyle-BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|
       Ridge|Inset|Outset"  
    ControlStyle-BorderWidth="size"  
    ControlStyle-CssClass="string" 
    ControlStyle-Font-Bold="true|false" 
    ControlStyle-Font-Italic="true|false" 
    ControlStyle-Font-Names="string" 
    ControlStyle-Font-Overline="true|false"  
    ControlStyle-Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
       Large|X-Large|XX-Large" 
    ControlStyle-Font-Strikeout="true|false"   
    ControlStyle-Font-Underline="true|false"   
    ControlStyle-ForeColor="color name|#dddddd"   
    ControlStyle-Height="size" 
    ControlStyle-Width="size" 
    ConvertEmptyStringToNull="true|false"  
    DataField="string" 
    DataFormatString="string"   
    FooterStyle-BackColor="color name|#dddddd" 
    FooterStyle-BorderColor="color name|#dddddd" 
    FooterStyle-BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|
       Ridge|Inset|Outset"  
    FooterStyle-BorderWidth="size"  
    FooterStyle-CssClass="string" 
    FooterStyle-Font-Bold="true|false" 
    FooterStyle-Font-Italic="true|false" 
    FooterStyle-Font-Names="string" 
    FooterStyle-Font-Overline="true|false"  
    FooterStyle-Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
       Large|X-Large|XX-Large" 
    FooterStyle-Font-Strikeout="true|false"   
    FooterStyle-Font-Underline="true|false"   
    FooterStyle-ForeColor="color name|#dddddd"   
    FooterStyle-Height="size" 
    FooterStyle-Width="size" 
    FooterStyle-HorizontalAlign="Center|Justify|Left|NotSet|Right" 
    FooterStyle-VerticalAlign="Bottom|Middle|NotSet|Top" 
    FooterStyle-Wrap="true|false"   
    HeaderImageUrl="uri"
    HeaderStyle-BackColor="color name|#dddddd" 
    HeaderStyle-BorderColor="color name|#dddddd" 
    HeaderStyle-BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|
       Ridge|Inset|Outset"  
    HeaderStyle-BorderWidth="size"  
    HeaderStyle-CssClass="string" 
    HeaderStyle-Font-Bold="true|false" 
    HeaderStyle-Font-Italic="true|false" 
    HeaderStyle-Font-Names="string" 
    HeaderStyle-Font-Overline="true|false"  
    HeaderStyle-Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
       Large|X-Large|XX-Large" 
    HeaderStyle-Font-Strikeout="true|false"   
    HeaderStyle-Font-Underline="true|false"   
    HeaderStyle-ForeColor="color name|#dddddd"   
    HeaderStyle-Height="size" 
    HeaderStyle-Width="size" 
    HeaderStyle-HorizontalAlign="Center|Justify|Left|NotSet|Right" 
    HeaderStyle-VerticalAlign="Bottom|Middle|NotSet|Top" 
    HeaderStyle-Wrap="true|false"   
    HeaderText="string"
    InsertVisible="true|false"    
    ItemStyle-BackColor="color name|#dddddd" 
    ItemStyle-BorderColor="color name|#dddddd" 
    ItemStyle-BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|
       Ridge|Inset|Outset"  
    ItemStyle-BorderWidth="size"  
    ItemStyle-CssClass="string" 
    ItemStyle-Font-Bold="true|false" 
    ItemStyle-Font-Italic="true|false" 
    ItemStyle-Font-Names="string" 
    ItemStyle-Font-Overline="true|false"  
    ItemStyle-Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
       Large|X-Large|XX-Large" 
    ItemStyle-Font-Strikeout="true|false"   
    ItemStyle-Font-Underline="true|false"   
    ItemStyle-ForeColor="color name|#dddddd"   
    ItemStyle-Height="size" 
    ItemStyle-Width="size" 
    ItemStyle-HorizontalAlign="Center|Justify|Left|NotSet|Right" 
    ItemStyle-VerticalAlign="Bottom|Middle|NotSet|Top" 
    ItemStyle-Wrap="true|false"   
    NullDisplayText="string" 
    ReadOnly="true|false"  
    ShowHeader="true|false"  
    SortExpression="string" 
    UIHint="string" 
    ValidationGroup="string" 
    Visible="true|false" 
    />
<asp:DynamicField />

See a run-time code example of this feature: Run.

The following example demonstrates how to use the DynamicField object in a GridView control to display and edit values from a database table.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  protected void Page_Init(object sender, EventArgs e)
  {
    DynamicDataManager1.RegisterControl(CustomersGridView);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>DynamicField Sample</title>
  <link href="~/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <form id="form1" runat="server">
    <div>

      <h2><%= CustomersDataSource.TableName%> Table</h2>

      <asp:DynamicDataManager ID="DynamicDataManager1" runat="server"
        AutoLoadForeignKeys="true" />

      <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true" 
        HeaderText="List of validation errors"  />
      <asp:DynamicValidator runat="server" ID="DynamicValidator1"
        ControlToValidate="CustomersGridView" Display="None" />

      <asp:GridView ID="CustomersGridView" runat="server"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true"
        AutoGenerateDeleteButton="true"
        DataSourceID="CustomersDataSource"
        AllowPaging="true"
        AllowSorting="true"
        CssClass="gridview">
        <Columns>
          <asp:DynamicField DataField="CustomerID" />
          <asp:DynamicField DataField="FirstName" />
          <asp:DynamicField DataField="LastName" />
        </Columns>        
      </asp:GridView>

      <!-- This example uses Microsoft SQL Server and connects   -->
      <!-- to the AdventureWorksLT sample database.              -->
      <asp:LinqDataSource ID="CustomersDataSource" runat="server" 
        TableName="Customers"
        ContextTypeName="AdventureWorksLTDataContext"
        EnableUpdate="true"
        EnableDelete="true" >
      </asp:LinqDataSource>

    </div>
  </form>
</body>
</html>

.NET Framework
Available since 3.5

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:
© 2016 Microsoft