Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / DataSourceHelper.cs / 1 / DataSourceHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Data; internal sealed class DataSourceHelper { private DataSourceHelper() { } internal static IEnumerable GetResolvedDataSource(object dataSource, string dataMember) { if (dataSource == null) return null; IListSource listSource = dataSource as IListSource; if (listSource != null) { IList memberList = listSource.GetList(); if (listSource.ContainsListCollection == false) { // the returned list is itself the list we need to bind to // NOTE: I am ignoring the DataMember parameter... ideally we might have // thrown an exception, but this would mess up design-time usage // where the user may change the data source from a DataSet to a // DataTable. return (IEnumerable)memberList; } if ((memberList != null) && (memberList is ITypedList)) { ITypedList typedMemberList = (ITypedList)memberList; PropertyDescriptorCollection propDescs = typedMemberList.GetItemProperties(new PropertyDescriptor[0]); if ((propDescs != null) && (propDescs.Count != 0)) { PropertyDescriptor listProperty = null; if (String.IsNullOrEmpty(dataMember)) { listProperty = propDescs[0]; } else { listProperty = propDescs.Find(dataMember, true); } if (listProperty != null) { object listRow = memberList[0]; object list = listProperty.GetValue(listRow); if ((list != null) && (list is IEnumerable)) { return (IEnumerable)list; } } throw new HttpException(SR.GetString(SR.ListSource_Missing_DataMember, dataMember)); } else { throw new HttpException(SR.GetString(SR.ListSource_Without_DataMembers)); } } } if (dataSource is IEnumerable) { return (IEnumerable)dataSource; } return null; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StrokeNodeData.cs
- ComplusEndpointConfigContainer.cs
- MsmqHostedTransportConfiguration.cs
- ScriptBehaviorDescriptor.cs
- ConfigurationElementProperty.cs
- AutomationTextAttribute.cs
- DbProviderConfigurationHandler.cs
- Util.cs
- AttributeData.cs
- TextReader.cs
- SchemaExporter.cs
- ApplicationInfo.cs
- RoutedEventArgs.cs
- SqlConnectionHelper.cs
- ItemContainerPattern.cs
- HtmlImageAdapter.cs
- BoundsDrawingContextWalker.cs
- XmlSchemaSimpleTypeRestriction.cs
- TransformDescriptor.cs
- SamlSecurityTokenAuthenticator.cs
- PreloadedPackages.cs
- SqlRecordBuffer.cs
- XmlArrayAttribute.cs
- XmlQueryContext.cs
- WebControlAdapter.cs
- ReflectionTypeLoadException.cs
- InputScope.cs
- ZoneMembershipCondition.cs
- StateChangeEvent.cs
- OpCopier.cs
- TheQuery.cs
- PropertyChangingEventArgs.cs
- ProviderBase.cs
- ConfigurationStrings.cs
- ControlEvent.cs
- RawStylusSystemGestureInputReport.cs
- COM2ExtendedBrowsingHandler.cs
- FrameworkElementFactory.cs
- CompiledQuery.cs
- TheQuery.cs
- BaseTemplateParser.cs
- SqlResolver.cs
- XhtmlBasicSelectionListAdapter.cs
- Rectangle.cs
- XmlCompatibilityReader.cs
- HtmlMeta.cs
- SoapEnumAttribute.cs
- Convert.cs
- ContentHostHelper.cs
- PointUtil.cs
- CollectionTraceRecord.cs
- DesignerSerializationOptionsAttribute.cs
- UIElementParaClient.cs
- AsyncOperation.cs
- ProjectionAnalyzer.cs
- RawStylusInputCustomData.cs
- LinkButton.cs
- HostSecurityManager.cs
- SafeFileMappingHandle.cs
- Expressions.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- HiddenFieldPageStatePersister.cs
- PtsHelper.cs
- GenericRootAutomationPeer.cs
- Button.cs
- DataGridViewCell.cs
- JavaScriptString.cs
- DataServiceSaveChangesEventArgs.cs
- SlotInfo.cs
- TabItemWrapperAutomationPeer.cs
- SynchronizedInputProviderWrapper.cs
- XmlILTrace.cs
- InvokeMethodDesigner.xaml.cs
- NavigationHelper.cs
- XmlSchemaSimpleTypeUnion.cs
- TextClipboardData.cs
- XmlHierarchicalDataSourceView.cs
- OdbcTransaction.cs
- PropertyMapper.cs
- ServiceDocumentFormatter.cs
- SqlXmlStorage.cs
- HttpWebResponse.cs
- EntitySqlQueryState.cs
- CoTaskMemHandle.cs
- Thumb.cs
- URI.cs
- SystemEvents.cs
- CheckBoxAutomationPeer.cs
- WebPartCatalogCloseVerb.cs
- CreateUserErrorEventArgs.cs
- BitmapSource.cs
- IfJoinedCondition.cs
- XmlBinaryWriter.cs
- ExpressionTable.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- DataGridViewDataConnection.cs
- MdiWindowListItemConverter.cs
- LocationUpdates.cs
- TraceFilter.cs
- EventSetter.cs