AutoGeneratedFieldProperties.DataField Property
.NET Framework (current version)
Gets or sets the name of the field bound to the AutoGeneratedField object.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.StringThe name of the field bound to the AutoGeneratedField. The default is an empty string (""), which indicates that this property is not set.
Use the DataField property to specify the name of the data field to bind to the AutoGeneratedField object. The AutoGeneratedField object automatically displays the values in the appropriate control, based on the Type property. For example, Boolean values are displayed in check box controls, while String values are displayed as plain text.
The following code example demonstrates how to use the DataField property to determine the value with which to set the DataField 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; } } }
.NET Framework
Available since 2.0
Available since 2.0
Show: