Code:
/ 4.0 / 4.0 / 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. Listfields = 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. 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
- RegisteredScript.cs
- ValidationService.cs
- TypeConverterAttribute.cs
- OrderByBuilder.cs
- ApplicationActivator.cs
- CompressEmulationStream.cs
- DeleteCardRequest.cs
- RelationshipFixer.cs
- PrintingPermission.cs
- ValidatorCompatibilityHelper.cs
- HttpCacheVary.cs
- TextSchema.cs
- KerberosTicketHashIdentifierClause.cs
- BigInt.cs
- XmlSerializationGeneratedCode.cs
- PropertyEmitterBase.cs
- OracleColumn.cs
- DisplayMemberTemplateSelector.cs
- RIPEMD160.cs
- BulletedListDesigner.cs
- CryptoSession.cs
- ServiceAuthorizationElement.cs
- DefaultProxySection.cs
- PkcsUtils.cs
- figurelengthconverter.cs
- InputManager.cs
- KeyedHashAlgorithm.cs
- WebPermission.cs
- HtmlWindow.cs
- Thread.cs
- AttributeCollection.cs
- XPathPatternBuilder.cs
- WebServiceMethodData.cs
- SamlNameIdentifierClaimResource.cs
- LambdaCompiler.Binary.cs
- DateTimeStorage.cs
- MatrixAnimationBase.cs
- ParseElement.cs
- BlurEffect.cs
- SequenceDesigner.cs
- OracleConnection.cs
- WinFormsSecurity.cs
- ComContractElement.cs
- LateBoundBitmapDecoder.cs
- DBConnectionString.cs
- NativeMethods.cs
- MethodAccessException.cs
- xdrvalidator.cs
- __Filters.cs
- MarshalByRefObject.cs
- CheckoutException.cs
- ChildrenQuery.cs
- DifferencingCollection.cs
- SubMenuStyle.cs
- CustomWebEventKey.cs
- FloaterBaseParagraph.cs
- DataConnectionHelper.cs
- PersonalizableAttribute.cs
- BaseDataList.cs
- ApplicationTrust.cs
- JsonEncodingStreamWrapper.cs
- WorkflowServiceHost.cs
- DrawItemEvent.cs
- InfoCardRSACryptoProvider.cs
- CommandConverter.cs
- BindingManagerDataErrorEventArgs.cs
- TrackingProfileSerializer.cs
- ExpressionValueEditor.cs
- SkewTransform.cs
- FocusTracker.cs
- XPathBinder.cs
- OleDbError.cs
- LogReservationCollection.cs
- PropertyConverter.cs
- ThicknessKeyFrameCollection.cs
- ReflectionPermission.cs
- IncomingWebResponseContext.cs
- EntityDataSourceContextDisposingEventArgs.cs
- SystemIcmpV4Statistics.cs
- ClientTarget.cs
- DesignerActionHeaderItem.cs
- DummyDataSource.cs
- Intellisense.cs
- ParagraphResult.cs
- EventLogPermission.cs
- PersonalizationProviderHelper.cs
- Image.cs
- Bezier.cs
- FieldNameLookup.cs
- FormatVersion.cs
- ClosableStream.cs
- ConfigurationLocationCollection.cs
- DnsPermission.cs
- KeyValueSerializer.cs
- linebase.cs
- TextEditorParagraphs.cs
- FlowDocumentPageViewerAutomationPeer.cs
- Msmq4SubqueuePoisonHandler.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- VisualTreeHelper.cs