Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / DefaultAutoFieldGenerator.cs / 1305376 / DefaultAutoFieldGenerator.cs
namespace System.Web.DynamicData {
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.DynamicData.Util;
using System.Web.UI;
using System.Web.UI.WebControls;
public class DefaultAutoFieldGenerator : IAutoFieldGenerator {
private IMetaTable _metaTable;
public DefaultAutoFieldGenerator(MetaTable table)
: this((IMetaTable)table) {
}
internal DefaultAutoFieldGenerator(IMetaTable table) {
if (table == null) {
throw new ArgumentNullException("table");
}
_metaTable = table;
}
public ICollection GenerateFields(Control control) {
DataBoundControlMode mode = GetMode(control);
ContainerType containerType = GetControlContainerType(control);
// Auto-generate fields from metadata.
List fields = new List();
foreach (MetaColumn column in _metaTable.GetScaffoldColumns(mode, containerType)) {
fields.Add(CreateField(column, containerType, mode));
}
return fields;
}
protected virtual DynamicField CreateField(MetaColumn column, ContainerType containerType, DataBoundControlMode mode) {
string headerText = (containerType == ContainerType.List ? column.ShortDisplayName : column.DisplayName);
var field = new DynamicField() {
DataField = column.Name,
HeaderText = headerText
};
// Turn wrapping off by default so that error messages don't show up on the next line.
field.ItemStyle.Wrap = false;
return field;
}
internal static ContainerType GetControlContainerType(Control control) {
#if !ORYX_VNEXT
if (control is IDataBoundListControl || control is Repeater) {
return ContainerType.List;
} else if (control is IDataBoundItemControl) {
return ContainerType.Item;
}
#else
if (control is GridView || control is ListView || control is Repeater) {
return ContainerType.List;
}
if (control is FormView || control is DetailsView) {
return ContainerType.Item;
}
#endif
return ContainerType.List;
}
internal static DataBoundControlMode GetMode(Control control) {
#if ORYX_VNEXT
return DataControlHelper.GetControlAdapter(control).Mode;
#else
// Only item controls have distinct modes
IDataBoundItemControl itemControl = control as IDataBoundItemControl;
if (itemControl != null && GetControlContainerType(control) != ContainerType.List) {
return itemControl.Mode;
}
return DataBoundControlMode.ReadOnly;
#endif
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpCachePolicy.cs
- FastEncoderWindow.cs
- ConfigurationStrings.cs
- DragStartedEventArgs.cs
- CollectionChangeEventArgs.cs
- PartBasedPackageProperties.cs
- TimeZone.cs
- PerformanceCounterPermission.cs
- Model3DCollection.cs
- DispatcherOperation.cs
- WebPartChrome.cs
- ProcessHost.cs
- DataObjectMethodAttribute.cs
- GuidConverter.cs
- HttpRequest.cs
- DataServiceProcessingPipeline.cs
- CommunicationException.cs
- Tokenizer.cs
- ISAPIRuntime.cs
- VisemeEventArgs.cs
- HashStream.cs
- CryptoApi.cs
- SignatureHelper.cs
- ContextMenu.cs
- PolyBezierSegment.cs
- CustomTrackingQuery.cs
- WSSecurityTokenSerializer.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- BaseServiceProvider.cs
- BooleanStorage.cs
- XomlCompiler.cs
- CounterNameConverter.cs
- StringAttributeCollection.cs
- RoleManagerSection.cs
- KeyboardDevice.cs
- DesignerToolboxInfo.cs
- OdbcStatementHandle.cs
- BuildProvider.cs
- IDispatchConstantAttribute.cs
- Facet.cs
- Byte.cs
- SimpleTextLine.cs
- QuaternionKeyFrameCollection.cs
- nulltextcontainer.cs
- SqlReferenceCollection.cs
- FontDifferentiator.cs
- EncryptedKeyIdentifierClause.cs
- PassportIdentity.cs
- DesignerForm.cs
- ConnectionManager.cs
- ThreadStaticAttribute.cs
- TemplateBamlTreeBuilder.cs
- MasterPageBuildProvider.cs
- DataGridViewSortCompareEventArgs.cs
- WindowInteractionStateTracker.cs
- DeflateEmulationStream.cs
- Listbox.cs
- MenuItemCollection.cs
- SystemFonts.cs
- TextTreeTextNode.cs
- WindowsGraphicsWrapper.cs
- ToolBar.cs
- XomlCompilerHelpers.cs
- StringAnimationBase.cs
- AssemblyAttributesGoHere.cs
- DynamicObject.cs
- HtmlInputText.cs
- BindToObject.cs
- FontEmbeddingManager.cs
- VBIdentifierTrimConverter.cs
- NavigationService.cs
- WebPartConnectionsDisconnectVerb.cs
- NameValueConfigurationElement.cs
- Buffer.cs
- SiteMapProvider.cs
- ContractMapping.cs
- WebServiceResponse.cs
- RegexTree.cs
- tooltip.cs
- XmlObjectSerializerReadContext.cs
- VirtualStackFrame.cs
- GPRECTF.cs
- ErrorFormatter.cs
- DataControlImageButton.cs
- DecimalFormatter.cs
- ListViewItem.cs
- Cursors.cs
- ExternalCalls.cs
- Object.cs
- RuntimeIdentifierPropertyAttribute.cs
- Matrix3DConverter.cs
- LeftCellWrapper.cs
- SafeLibraryHandle.cs
- TreeWalkHelper.cs
- EastAsianLunisolarCalendar.cs
- ClientTargetSection.cs
- StylusEditingBehavior.cs
- CodeCatchClause.cs
- ReadOnlyAttribute.cs
- CodeStatementCollection.cs