Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / WebControls / FilteredDataSetHelper.cs / 2 / FilteredDataSetHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Globalization; using System.Web.Util; ////// Helper class for SqlDataSource and ObjectDataSource. /// internal static class FilteredDataSetHelper { public static DataView CreateFilteredDataView(DataTable table, string sortExpression, string filterExpression, IDictionary filterParameters) { Debug.Assert(table != null, "Did not expect null table"); Debug.Assert(sortExpression != null, "Did not expect null sort expression"); Debug.Assert(filterExpression != null, "Did not expect null filter expression"); DataView dv = new DataView(table); // Set sort expression if (!String.IsNullOrEmpty(sortExpression)) { dv.Sort = sortExpression; } // Set filter expression if (!String.IsNullOrEmpty(filterExpression)) { bool hasNulls = false; Debug.Assert(filterParameters != null, "Did not expect null filter parameters when a filter expression was set"); object[] values = new object[filterParameters.Count]; int index = 0; foreach (DictionaryEntry de in filterParameters) { if (de.Value == null) { hasNulls = true; break; } values[index] = de.Value; index++; } filterExpression = String.Format(CultureInfo.InvariantCulture, filterExpression, values); // Filter expression should only be applied if there were no null parameters if (!hasNulls) { dv.RowFilter = filterExpression; } } return dv; } public static DataTable GetDataTable(Control owner, object dataObject) { DataSet dataSet = dataObject as DataSet; if (dataSet != null) { if (dataSet.Tables.Count == 0) { throw new InvalidOperationException(SR.GetString(SR.FilteredDataSetHelper_DataSetHasNoTables, owner.ID)); } return dataSet.Tables[0]; } else { return dataObject as DataTable; } } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HostingEnvironmentWrapper.cs
- CannotUnloadAppDomainException.cs
- PersistencePipeline.cs
- Animatable.cs
- ConfigurationProperty.cs
- KeyInfo.cs
- DesignerObject.cs
- Parallel.cs
- InvalidOleVariantTypeException.cs
- EntityContainerRelationshipSetEnd.cs
- Setter.cs
- ClientSettingsSection.cs
- BitmapEffectGroup.cs
- CodeIdentifier.cs
- StylusLogic.cs
- HtmlControl.cs
- Scene3D.cs
- FeatureSupport.cs
- Rotation3DAnimationUsingKeyFrames.cs
- Token.cs
- TriState.cs
- UrlPath.cs
- ExceptionUtility.cs
- PageContent.cs
- Tool.cs
- AnonymousIdentificationSection.cs
- MetafileHeaderWmf.cs
- XamlReaderHelper.cs
- TextElementCollection.cs
- WinFormsSecurity.cs
- EntityViewGenerationAttribute.cs
- connectionpool.cs
- InvalidProgramException.cs
- CurrencyManager.cs
- SrgsRule.cs
- SizeAnimationBase.cs
- SqlRowUpdatedEvent.cs
- SoapIgnoreAttribute.cs
- EventDescriptor.cs
- SimpleHandlerFactory.cs
- AmbientValueAttribute.cs
- ServiceElement.cs
- SafePointer.cs
- HtmlTextArea.cs
- SiteMapProvider.cs
- TableRowGroup.cs
- Exception.cs
- RequiredFieldValidator.cs
- SqlProfileProvider.cs
- DesignerUtility.cs
- DbConnectionOptions.cs
- ComponentChangingEvent.cs
- XmlReflectionImporter.cs
- ClockGroup.cs
- CrossContextChannel.cs
- HttpInputStream.cs
- AuthenticationSection.cs
- Label.cs
- TemplateColumn.cs
- DiscoveryMessageSequenceCD1.cs
- SignatureSummaryDialog.cs
- Symbol.cs
- ASCIIEncoding.cs
- DecoderNLS.cs
- ErrorWebPart.cs
- WindowsPen.cs
- TrackingRecord.cs
- EventLogger.cs
- ProfileSettings.cs
- OverflowException.cs
- DiscoveryUtility.cs
- CqlParserHelpers.cs
- DynamicDataRouteHandler.cs
- HitTestDrawingContextWalker.cs
- ThemeableAttribute.cs
- PolygonHotSpot.cs
- NextPreviousPagerField.cs
- WindowsFont.cs
- IdentitySection.cs
- SaveFileDialog.cs
- ToolStripButton.cs
- TemplateNameScope.cs
- PropertyChangedEventArgs.cs
- MemoryMappedView.cs
- LoginView.cs
- JpegBitmapDecoder.cs
- TileBrush.cs
- WsatConfiguration.cs
- DeferredRunTextReference.cs
- ExponentialEase.cs
- GeometryHitTestResult.cs
- Convert.cs
- Pair.cs
- HeaderedItemsControl.cs
- baseaxisquery.cs
- Vector3DAnimation.cs
- LinqDataSourceDisposeEventArgs.cs
- TagPrefixCollection.cs
- DayRenderEvent.cs
- HtmlTextArea.cs