Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / TemplateColumn.cs / 1 / TemplateColumn.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
///
/// Defines the template for controls layout within a
///
/// column.
///
//
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class TemplateColumn : DataGridColumn {
private ITemplate headerTemplate;
private ITemplate footerTemplate;
private ITemplate itemTemplate;
private ITemplate editItemTemplate;
///
/// Initializes a new instance of the class.
///
public TemplateColumn() {
}
///
/// Specifies the that defines how items in edit mode are rendered.
///
[
Browsable(false),
DefaultValue(null),
WebSysDescription(SR.TemplateColumn_EditItemTemplate),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(DataGridItem))
]
public virtual ITemplate EditItemTemplate {
get {
return editItemTemplate;
}
set {
editItemTemplate = value;
OnColumnChanged();
}
}
///
/// Specifies the that defines how the control footer is rendered.
///
[
Browsable(false),
DefaultValue(null),
WebSysDescription(SR.TemplateColumn_FooterTemplate),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(DataGridItem))
]
public virtual ITemplate FooterTemplate {
get {
return footerTemplate;
}
set {
footerTemplate = value;
OnColumnChanged();
}
}
///
/// Specifies the
/// that defines how the control header is rendered.
///
[
Browsable(false),
DefaultValue(null),
WebSysDescription(SR.TemplateColumn_HeaderTemplate),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(DataGridItem))
]
public virtual ITemplate HeaderTemplate {
get {
return headerTemplate;
}
set {
headerTemplate = value;
OnColumnChanged();
}
}
///
/// Specifies the that defines how items are rendered.
///
[
Browsable(false),
DefaultValue(null),
WebSysDescription(SR.TemplateColumn_ItemTemplate),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(DataGridItem))
]
public virtual ITemplate ItemTemplate {
get {
return itemTemplate;
}
set {
itemTemplate = value;
OnColumnChanged();
}
}
///
///
///
public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType) {
base.InitializeCell(cell, columnIndex, itemType);
ITemplate contentTemplate = null;
switch (itemType) {
case ListItemType.Header:
contentTemplate = headerTemplate;
break;
case ListItemType.Footer:
contentTemplate = footerTemplate;
break;
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
contentTemplate = itemTemplate;
break;
case ListItemType.EditItem:
if (editItemTemplate != null)
contentTemplate = editItemTemplate;
else
goto case ListItemType.Item;
break;
}
if (contentTemplate != null) {
// The base class might have added a control or some text for some cases
// such as header text which need to be removed before
// the corresponding template is used.
// Note that setting text also has the effect of clearing out any controls.
cell.Text = String.Empty;
contentTemplate.InstantiateIn(cell);
}
else {
if (itemType == ListItemType.Item ||
itemType == ListItemType.AlternatingItem ||
itemType == ListItemType.SelectedItem ||
itemType == ListItemType.EditItem) {
cell.Text = " ";
}
}
}
}
}
// 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
- WaitHandleCannotBeOpenedException.cs
- DataStreams.cs
- ClientRuntimeConfig.cs
- Content.cs
- PresentationAppDomainManager.cs
- MouseActionValueSerializer.cs
- Color.cs
- BatchServiceHost.cs
- SiteMapNodeCollection.cs
- relpropertyhelper.cs
- AutomationElementCollection.cs
- FolderNameEditor.cs
- PerformanceCounterLib.cs
- TypeDescriptor.cs
- ApplicationDirectoryMembershipCondition.cs
- SecurityCriticalDataForSet.cs
- ProtectedConfiguration.cs
- GridViewDesigner.cs
- VectorCollection.cs
- ForEachAction.cs
- GenericRootAutomationPeer.cs
- DescendentsWalkerBase.cs
- AttachedPropertyDescriptor.cs
- DateTimeSerializationSection.cs
- IDQuery.cs
- ListViewInsertionMark.cs
- PassportIdentity.cs
- DesignerCategoryAttribute.cs
- BasicDesignerLoader.cs
- ReadOnlyAttribute.cs
- Content.cs
- OleAutBinder.cs
- ImageSourceValueSerializer.cs
- LinqToSqlWrapper.cs
- SqlTriggerContext.cs
- AgileSafeNativeMemoryHandle.cs
- DirectoryNotFoundException.cs
- DataSourceControlBuilder.cs
- PropertyChangedEventArgs.cs
- UpdateEventArgs.cs
- TrackingProfile.cs
- _SSPISessionCache.cs
- Tokenizer.cs
- LineServicesCallbacks.cs
- FlowLayoutSettings.cs
- BooleanKeyFrameCollection.cs
- SqlTriggerContext.cs
- NetStream.cs
- CoreSwitches.cs
- DragEventArgs.cs
- XmlNamespaceMapping.cs
- SAPIEngineTypes.cs
- LinkLabel.cs
- DeploymentSection.cs
- EntityFrameworkVersions.cs
- GlyphsSerializer.cs
- TemplateControlParser.cs
- Journaling.cs
- XPathExpr.cs
- FormsAuthentication.cs
- XmlSchemaValidator.cs
- ErrorWrapper.cs
- BezierSegment.cs
- WindowsClaimSet.cs
- ScriptComponentDescriptor.cs
- CodeValidator.cs
- UnauthorizedAccessException.cs
- SqlDataReader.cs
- Line.cs
- RsaKeyGen.cs
- ShaperBuffers.cs
- XmlValidatingReader.cs
- SequentialUshortCollection.cs
- RowUpdatedEventArgs.cs
- SizeLimitedCache.cs
- ExpressionDumper.cs
- ServiceRoute.cs
- InternalsVisibleToAttribute.cs
- TrustExchangeException.cs
- DiffuseMaterial.cs
- SqlSupersetValidator.cs
- processwaithandle.cs
- FilterableAttribute.cs
- Hash.cs
- DiscoveryInnerClientAdhoc11.cs
- HtmlButton.cs
- AsyncContentLoadedEventArgs.cs
- DocumentSequence.cs
- XmlBufferReader.cs
- ScrollChrome.cs
- BinaryObjectInfo.cs
- BinaryUtilClasses.cs
- ServicePoint.cs
- WeakHashtable.cs
- InvokeProviderWrapper.cs
- ResourceDisplayNameAttribute.cs
- TextEditorLists.cs
- ClockGroup.cs
- BinaryObjectWriter.cs
- MarkupWriter.cs