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. 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ArraySegment.cs
- WsatAdminException.cs
- Sql8ExpressionRewriter.cs
- HttpApplicationFactory.cs
- DriveNotFoundException.cs
- OdbcEnvironment.cs
- XmlElementList.cs
- WebEvents.cs
- XmlSigningNodeWriter.cs
- ProfilePropertyMetadata.cs
- TypeTypeConverter.cs
- CodeCommentStatementCollection.cs
- DocumentScope.cs
- EventMap.cs
- HttpApplicationFactory.cs
- BaseTemplateParser.cs
- DataRow.cs
- ISFTagAndGuidCache.cs
- PageBuildProvider.cs
- CustomErrorCollection.cs
- RectAnimationUsingKeyFrames.cs
- RelOps.cs
- ParseNumbers.cs
- RoutedEventValueSerializer.cs
- MD5CryptoServiceProvider.cs
- WinFormsComponentEditor.cs
- RegexBoyerMoore.cs
- TransactionManager.cs
- CustomCredentialPolicy.cs
- PaintEvent.cs
- MouseOverProperty.cs
- WebEvents.cs
- XmlSchemaDatatype.cs
- ScopeCompiler.cs
- oledbmetadatacolumnnames.cs
- ComponentResourceManager.cs
- Internal.cs
- X509ChainPolicy.cs
- DynamicArgumentDesigner.xaml.cs
- MethodToken.cs
- MsmqIntegrationValidationBehavior.cs
- WebZone.cs
- Rotation3DAnimation.cs
- UIElement3D.cs
- SpecularMaterial.cs
- XmlUtil.cs
- XmlSchemaParticle.cs
- DocumentEventArgs.cs
- InstancePersistenceContext.cs
- DetailsViewInsertEventArgs.cs
- DeclarativeCatalogPartDesigner.cs
- SQLInt32Storage.cs
- DropDownHolder.cs
- Validator.cs
- TraceShell.cs
- SmtpNetworkElement.cs
- CommandManager.cs
- KeyManager.cs
- DataGridItem.cs
- EntityDataSourceMemberPath.cs
- Assembly.cs
- InkCanvasFeedbackAdorner.cs
- Span.cs
- EntityDataSourceState.cs
- XmlSchemaSet.cs
- WebExceptionStatus.cs
- HttpHandlersSection.cs
- MobileFormsAuthentication.cs
- LabelInfo.cs
- SafeEventLogWriteHandle.cs
- CultureTableRecord.cs
- PenThread.cs
- PerfService.cs
- PortCache.cs
- OracleMonthSpan.cs
- XmlElementList.cs
- ImportContext.cs
- FontCacheUtil.cs
- SQLDouble.cs
- validationstate.cs
- AccessDataSource.cs
- CodeConditionStatement.cs
- StrongNameSignatureInformation.cs
- StyleTypedPropertyAttribute.cs
- MonthCalendar.cs
- PersistenceProviderFactory.cs
- EllipseGeometry.cs
- InputBindingCollection.cs
- SpnegoTokenAuthenticator.cs
- Rect3DValueSerializer.cs
- XhtmlStyleClass.cs
- SelectionHighlightInfo.cs
- DatatypeImplementation.cs
- NameValueCollection.cs
- HttpStaticObjectsCollectionWrapper.cs
- linebase.cs
- DataControlFieldCell.cs
- TaskSchedulerException.cs
- ProgressBarRenderer.cs
- StringDictionary.cs