Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebControls / DataControlFieldCollection.cs / 1 / DataControlFieldCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
///
/// Represents the collection of fields to be displayed in
/// a data bound control that uses fields.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class DataControlFieldCollection : StateManagedCollection {
private static readonly Type[] knownTypes = new Type[] {
typeof(BoundField),
typeof(ButtonField),
typeof(CheckBoxField),
typeof(CommandField),
typeof(HyperLinkField),
typeof(ImageField),
typeof(TemplateField)
};
public event EventHandler FieldsChanged;
///
/// Gets a at the specified index in the
/// collection.
///
[
Browsable(false)
]
public DataControlField this[int index] {
get {
return ((IList)this)[index] as DataControlField;
}
}
///
/// Appends a to the collection.
///
public void Add(DataControlField field) {
((IList)this).Add(field);
}
///
/// Provides a deep copy of the collection. Used mainly by design time dialogs to implement "cancel" rollback behavior.
///
public DataControlFieldCollection CloneFields() {
DataControlFieldCollection fields = new DataControlFieldCollection();
foreach (DataControlField field in this) {
fields.Add(field.CloneField());
}
return fields;
}
///
/// Returns whether a DataControlField is a member of the collection.
///
public bool Contains(DataControlField field) {
return ((IList)this).Contains(field);
}
///
/// Copies the contents of the entire collection into an appending at
/// the specified index of the .
///
public void CopyTo(DataControlField[] array, int index) {
((IList)this).CopyTo(array, index);
return;
}
///
/// Creates a known type of DataControlField.
///
protected override object CreateKnownType(int index) {
switch (index) {
case 0:
return new BoundField();
case 1:
return new ButtonField();
case 2:
return new CheckBoxField();
case 3:
return new CommandField();
case 4:
return new HyperLinkField();
case 5:
return new ImageField();
case 6:
return new TemplateField();
default:
throw new ArgumentOutOfRangeException(SR.GetString(SR.DataControlFieldCollection_InvalidTypeIndex));
}
}
///
/// Returns an ArrayList of known DataControlField types.
///
protected override Type[] GetKnownTypes() {
return knownTypes;
}
///
/// Returns the index of the first occurrence of a value in a .
///
public int IndexOf(DataControlField field) {
return ((IList)this).IndexOf(field);
}
///
/// Inserts a to the collection
/// at the specified index.
///
public void Insert(int index, DataControlField field) {
((IList)this).Insert(index, field);
}
///
/// Called when the Clear() method is complete.
///
protected override void OnClearComplete() {
OnFieldsChanged();
}
///
///
void OnFieldChanged(object sender, EventArgs e) {
OnFieldsChanged();
}
///
///
void OnFieldsChanged() {
if (FieldsChanged != null) {
FieldsChanged(this, EventArgs.Empty);
}
}
///
/// Called when the Insert() method is complete.
///
protected override void OnInsertComplete(int index, object value) {
DataControlField field = value as DataControlField;
if (field != null) {
field.FieldChanged += new EventHandler(OnFieldChanged);
}
OnFieldsChanged();
}
///
/// Called when the Remove() method is complete.
///
protected override void OnRemoveComplete(int index, object value) {
DataControlField field = value as DataControlField;
if (field != null) {
field.FieldChanged -= new EventHandler(OnFieldChanged);
}
OnFieldsChanged();
}
///
/// Validates that an object is a HotSpot.
///
protected override void OnValidate(object o) {
base.OnValidate(o);
if (!(o is DataControlField))
throw new ArgumentException(SR.GetString(SR.DataControlFieldCollection_InvalidType));
}
///
/// Removes a from the collection at the specified
/// index.
///
public void RemoveAt(int index) {
((IList)this).RemoveAt(index);
}
///
/// Removes the specified from the collection.
///
public void Remove(DataControlField field) {
((IList)this).Remove(field);
}
///
/// Marks a DataControlField as dirty so that it will record its entire state into view state.
///
protected override void SetDirtyObject(object o) {
((DataControlField)o).SetDirty();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
///
/// Represents the collection of fields to be displayed in
/// a data bound control that uses fields.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class DataControlFieldCollection : StateManagedCollection {
private static readonly Type[] knownTypes = new Type[] {
typeof(BoundField),
typeof(ButtonField),
typeof(CheckBoxField),
typeof(CommandField),
typeof(HyperLinkField),
typeof(ImageField),
typeof(TemplateField)
};
public event EventHandler FieldsChanged;
///
/// Gets a at the specified index in the
/// collection.
///
[
Browsable(false)
]
public DataControlField this[int index] {
get {
return ((IList)this)[index] as DataControlField;
}
}
///
/// Appends a to the collection.
///
public void Add(DataControlField field) {
((IList)this).Add(field);
}
///
/// Provides a deep copy of the collection. Used mainly by design time dialogs to implement "cancel" rollback behavior.
///
public DataControlFieldCollection CloneFields() {
DataControlFieldCollection fields = new DataControlFieldCollection();
foreach (DataControlField field in this) {
fields.Add(field.CloneField());
}
return fields;
}
///
/// Returns whether a DataControlField is a member of the collection.
///
public bool Contains(DataControlField field) {
return ((IList)this).Contains(field);
}
///
/// Copies the contents of the entire collection into an appending at
/// the specified index of the .
///
public void CopyTo(DataControlField[] array, int index) {
((IList)this).CopyTo(array, index);
return;
}
///
/// Creates a known type of DataControlField.
///
protected override object CreateKnownType(int index) {
switch (index) {
case 0:
return new BoundField();
case 1:
return new ButtonField();
case 2:
return new CheckBoxField();
case 3:
return new CommandField();
case 4:
return new HyperLinkField();
case 5:
return new ImageField();
case 6:
return new TemplateField();
default:
throw new ArgumentOutOfRangeException(SR.GetString(SR.DataControlFieldCollection_InvalidTypeIndex));
}
}
///
/// Returns an ArrayList of known DataControlField types.
///
protected override Type[] GetKnownTypes() {
return knownTypes;
}
///
/// Returns the index of the first occurrence of a value in a .
///
public int IndexOf(DataControlField field) {
return ((IList)this).IndexOf(field);
}
///
/// Inserts a to the collection
/// at the specified index.
///
public void Insert(int index, DataControlField field) {
((IList)this).Insert(index, field);
}
///
/// Called when the Clear() method is complete.
///
protected override void OnClearComplete() {
OnFieldsChanged();
}
///
///
void OnFieldChanged(object sender, EventArgs e) {
OnFieldsChanged();
}
///
///
void OnFieldsChanged() {
if (FieldsChanged != null) {
FieldsChanged(this, EventArgs.Empty);
}
}
///
/// Called when the Insert() method is complete.
///
protected override void OnInsertComplete(int index, object value) {
DataControlField field = value as DataControlField;
if (field != null) {
field.FieldChanged += new EventHandler(OnFieldChanged);
}
OnFieldsChanged();
}
///
/// Called when the Remove() method is complete.
///
protected override void OnRemoveComplete(int index, object value) {
DataControlField field = value as DataControlField;
if (field != null) {
field.FieldChanged -= new EventHandler(OnFieldChanged);
}
OnFieldsChanged();
}
///
/// Validates that an object is a HotSpot.
///
protected override void OnValidate(object o) {
base.OnValidate(o);
if (!(o is DataControlField))
throw new ArgumentException(SR.GetString(SR.DataControlFieldCollection_InvalidType));
}
///
/// Removes a from the collection at the specified
/// index.
///
public void RemoveAt(int index) {
((IList)this).RemoveAt(index);
}
///
/// Removes the specified from the collection.
///
public void Remove(DataControlField field) {
((IList)this).Remove(field);
}
///
/// Marks a DataControlField as dirty so that it will record its entire state into view state.
///
protected override void SetDirtyObject(object o) {
((DataControlField)o).SetDirty();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InputLanguageSource.cs
- ReliableSessionElement.cs
- TextReader.cs
- WindowsIdentity.cs
- XmlIgnoreAttribute.cs
- ADMembershipProvider.cs
- OleStrCAMarshaler.cs
- TextOnlyOutput.cs
- TrackingStringDictionary.cs
- ImageBrush.cs
- PngBitmapDecoder.cs
- SchemaImporterExtension.cs
- DispatcherTimer.cs
- SolidColorBrush.cs
- FindCriteria11.cs
- TrackingMemoryStream.cs
- XmlSchemaAttribute.cs
- PseudoWebRequest.cs
- SessionPageStateSection.cs
- CodeTypeDeclarationCollection.cs
- RegexWriter.cs
- MatrixTransform3D.cs
- CommandDevice.cs
- RequestQueue.cs
- UIElement3D.cs
- EdmType.cs
- ValidationPropertyAttribute.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- InspectionWorker.cs
- XmlElementCollection.cs
- ObjectDataSourceFilteringEventArgs.cs
- PaperSize.cs
- CommonDialog.cs
- ThreadPool.cs
- RelationshipEnd.cs
- AuthStoreRoleProvider.cs
- ResourceReferenceExpressionConverter.cs
- ArithmeticLiteral.cs
- LocalizedNameDescriptionPair.cs
- DictationGrammar.cs
- TreeNodeStyleCollection.cs
- GeometryConverter.cs
- BigIntegerStorage.cs
- DataGridViewButtonCell.cs
- WindowsTreeView.cs
- SymmetricAlgorithm.cs
- ResourceReader.cs
- StronglyTypedResourceBuilder.cs
- PersonalizationProvider.cs
- CacheOutputQuery.cs
- RNGCryptoServiceProvider.cs
- StateElement.cs
- DataGridViewComboBoxColumn.cs
- ExpressionUtilities.cs
- Stack.cs
- EventProviderClassic.cs
- Paragraph.cs
- ImageBrush.cs
- SponsorHelper.cs
- EllipseGeometry.cs
- OleDbSchemaGuid.cs
- WebBrowserBase.cs
- CodeTypeConstructor.cs
- StringFreezingAttribute.cs
- XmlQuerySequence.cs
- AbstractExpressions.cs
- WaitHandleCannotBeOpenedException.cs
- Perspective.cs
- SQLBinaryStorage.cs
- TreeWalker.cs
- DataFieldCollectionEditor.cs
- WebControl.cs
- SamlConstants.cs
- XmlDocumentType.cs
- FontClient.cs
- ConstraintManager.cs
- DbProviderSpecificTypePropertyAttribute.cs
- WindowsRebar.cs
- CodeRemoveEventStatement.cs
- OutputCacheModule.cs
- SingleObjectCollection.cs
- SystemUdpStatistics.cs
- TaskScheduler.cs
- CustomSignedXml.cs
- UpdateCompiler.cs
- MILUtilities.cs
- DBDataPermission.cs
- configsystem.cs
- LineInfo.cs
- XmlSchemaCollection.cs
- WebPartTransformer.cs
- StringComparer.cs
- JsonClassDataContract.cs
- KeySpline.cs
- TemplateDefinition.cs
- UrlMappingCollection.cs
- Operators.cs
- ScriptingWebServicesSectionGroup.cs
- PerspectiveCamera.cs
- WinHttpWebProxyFinder.cs