Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / WebControls / DataListItem.cs / 1 / DataListItem.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Security.Permissions;
///
/// Represents an item in the .
///
[
ToolboxItem(false)
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class DataListItem : WebControl, IDataItemContainer {
private int itemIndex;
private ListItemType itemType;
private object dataItem;
///
/// Initializes a new instance of the class.
///
public DataListItem(int itemIndex, ListItemType itemType) {
this.itemIndex = itemIndex;
this.itemType = itemType;
}
///
/// Represents an item in the .
///
public virtual object DataItem {
get {
return dataItem;
}
set {
dataItem = value;
}
}
///
/// Indicates the index of the item in the . This property is
/// read-only.
///
public virtual int ItemIndex {
get {
return itemIndex;
}
}
///
/// Indicates the type of the item in the .
///
public virtual ListItemType ItemType {
get {
return itemType;
}
}
///
///
protected override Style CreateControlStyle() {
return new TableItemStyle();
}
///
///
///
protected override bool OnBubbleEvent(object source, EventArgs e) {
if (e is CommandEventArgs) {
DataListCommandEventArgs args = new DataListCommandEventArgs(this, source, (CommandEventArgs)e);
RaiseBubbleEvent(this, args);
return true;
}
return false;
}
///
/// Displays a on the client.
///
public virtual void RenderItem(HtmlTextWriter writer, bool extractRows, bool tableLayout) {
HttpContext con = Context;
if ((con != null) && con.TraceIsEnabled) {
int presize = con.Response.GetBufferedLength();
RenderItemInternal(writer, extractRows, tableLayout);
int postsize = con.Response.GetBufferedLength();
con.Trace.AddControlSize(UniqueID, postsize - presize);
}
else
RenderItemInternal(writer, extractRows, tableLayout);
}
private void RenderItemInternal(HtmlTextWriter writer, bool extractRows, bool tableLayout) {
if (extractRows == false) {
if (tableLayout) {
// in table mode, style information has gone on the containing TD
RenderContents(writer);
}
else {
// in non-table mode, the item itself is responsible for putting
// out the style information
RenderControl(writer);
}
}
else {
IEnumerator controlEnum = this.Controls.GetEnumerator();
Table templateTable = null;
bool hasControls = false;
while (controlEnum.MoveNext()) {
hasControls = true;
Control c = (Control)controlEnum.Current;
if (c is Table) {
templateTable = (Table)c;
break;
}
}
if (templateTable != null) {
IEnumerator rowEnum = templateTable.Rows.GetEnumerator();
while (rowEnum.MoveNext()) {
TableRow r = (TableRow)rowEnum.Current;
r.RenderControl(writer);
}
}
else if (hasControls) {
// there was a template, since there were controls but
// none of them was a table... so throw an exception here
throw new HttpException(SR.GetString(SR.DataList_TemplateTableNotFound,
Parent.ID, itemType.ToString()));
}
}
}
///
///
///
protected internal virtual void SetItemType(ListItemType itemType) {
this.itemType = itemType;
}
///
///
///
object IDataItemContainer.DataItem {
get {
return DataItem;
}
}
int IDataItemContainer.DataItemIndex {
get {
return ItemIndex;
}
}
int IDataItemContainer.DisplayIndex {
get {
return ItemIndex;
}
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- recordstatescratchpad.cs
- SchemaImporterExtensionsSection.cs
- assemblycache.cs
- ClassicBorderDecorator.cs
- LambdaCompiler.Logical.cs
- COM2TypeInfoProcessor.cs
- ControlDesigner.cs
- PrincipalPermission.cs
- SqlParameterizer.cs
- FixedSOMPageConstructor.cs
- FtpWebResponse.cs
- RuntimeEnvironment.cs
- SymbolType.cs
- CookieHandler.cs
- namescope.cs
- SelectedCellsChangedEventArgs.cs
- ChildTable.cs
- Queue.cs
- PageStatePersister.cs
- CommandValueSerializer.cs
- OutputCacheSettingsSection.cs
- Screen.cs
- _Win32.cs
- FixedDocumentSequencePaginator.cs
- ConditionBrowserDialog.cs
- SecurityTokenException.cs
- QilFactory.cs
- CalendarTable.cs
- Menu.cs
- RoleServiceManager.cs
- ProcessInputEventArgs.cs
- DesignSurfaceManager.cs
- StringInfo.cs
- SoapProtocolImporter.cs
- IntegrationExceptionEventArgs.cs
- OnOperation.cs
- QueryGeneratorBase.cs
- LayoutEvent.cs
- BitmapEffectInputConnector.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- FunctionImportMapping.cs
- SerTrace.cs
- autovalidator.cs
- CatchDesigner.xaml.cs
- LabelTarget.cs
- ToolStripDropDownButton.cs
- DefaultObjectMappingItemCollection.cs
- FileLogRecordHeader.cs
- IndividualDeviceConfig.cs
- ResourceWriter.cs
- OSFeature.cs
- ConnectionStringsSection.cs
- MetadataPropertyvalue.cs
- LongTypeConverter.cs
- HtmlElementErrorEventArgs.cs
- TimelineGroup.cs
- ToolStripScrollButton.cs
- RectangleGeometry.cs
- CompiledQuery.cs
- TraceSource.cs
- MulticastIPAddressInformationCollection.cs
- ExtendedTransformFactory.cs
- RadialGradientBrush.cs
- WebPartCollection.cs
- SoapWriter.cs
- GlobalItem.cs
- TemplateApplicationHelper.cs
- RadioButtonFlatAdapter.cs
- GlyphRun.cs
- CompositeActivityValidator.cs
- SystemIPv4InterfaceProperties.cs
- OperationContractGenerationContext.cs
- XmlText.cs
- XhtmlBasicTextViewAdapter.cs
- OleDbWrapper.cs
- PointLight.cs
- SiteMapNodeItemEventArgs.cs
- UnorderedHashRepartitionStream.cs
- TraceUtils.cs
- EventMappingSettings.cs
- XpsPartBase.cs
- TableLayoutStyleCollection.cs
- StaticContext.cs
- SafeLocalMemHandle.cs
- NavigationWindowAutomationPeer.cs
- ViewGenResults.cs
- XslCompiledTransform.cs
- OdbcEnvironment.cs
- StreamingContext.cs
- DbSourceCommand.cs
- GridLength.cs
- FeatureSupport.cs
- InvokeMethodDesigner.xaml.cs
- MappingMetadataHelper.cs
- CommentGlyph.cs
- WebPartHelpVerb.cs
- TextEditorCopyPaste.cs
- ClusterSafeNativeMethods.cs
- GenerateScriptTypeAttribute.cs
- ThicknessConverter.cs