Code:
/ FX-1434 / FX-1434 / 1.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
- BaseAsyncResult.cs
- FocusWithinProperty.cs
- RuleSettingsCollection.cs
- DoubleSumAggregationOperator.cs
- ReceiveDesigner.xaml.cs
- DesignerActionHeaderItem.cs
- SynchronizedDispatch.cs
- RegionInfo.cs
- GlyphRunDrawing.cs
- ProjectionPruner.cs
- ColorTransform.cs
- TabControlAutomationPeer.cs
- RuntimeArgumentHandle.cs
- OuterGlowBitmapEffect.cs
- SerializationStore.cs
- DBConnectionString.cs
- RowBinding.cs
- SystemIPAddressInformation.cs
- XmlBinaryReader.cs
- SoapCodeExporter.cs
- ISFClipboardData.cs
- MissingManifestResourceException.cs
- XamlBuildTaskServices.cs
- SecurityHelper.cs
- Query.cs
- Preprocessor.cs
- ClientProxyGenerator.cs
- ProfileModule.cs
- Accessible.cs
- FontDifferentiator.cs
- EdgeModeValidation.cs
- DiffuseMaterial.cs
- DataReaderContainer.cs
- RoutedCommand.cs
- AttachedAnnotation.cs
- RemotingConfigParser.cs
- GeneralTransform2DTo3DTo2D.cs
- UrlAuthFailureHandler.cs
- HttpListenerContext.cs
- ListControl.cs
- KerberosSecurityTokenProvider.cs
- SystemColors.cs
- EditorPartCollection.cs
- VisualTreeHelper.cs
- TypefaceCollection.cs
- _SslSessionsCache.cs
- GPRECT.cs
- Underline.cs
- XPathNavigatorReader.cs
- ColumnTypeConverter.cs
- LogicalExpr.cs
- SimpleModelProvider.cs
- SchemaInfo.cs
- Hex.cs
- GridErrorDlg.cs
- IntegerFacetDescriptionElement.cs
- ADMembershipProvider.cs
- Serializer.cs
- PreloadedPackages.cs
- FormsAuthenticationCredentials.cs
- XslTransform.cs
- _IPv6Address.cs
- XmlSchemaNotation.cs
- SecurityIdentifierConverter.cs
- TimeSpanStorage.cs
- DataListItemEventArgs.cs
- FontSourceCollection.cs
- NameScope.cs
- _ConnectionGroup.cs
- PageContentCollection.cs
- AnnotationAdorner.cs
- ReadOnlyDictionary.cs
- Atom10FeedFormatter.cs
- GeneralTransformGroup.cs
- TextEncodedRawTextWriter.cs
- AttributeTableBuilder.cs
- HyperLinkDataBindingHandler.cs
- NativeMethods.cs
- UICuesEvent.cs
- MainMenu.cs
- RemoteHelper.cs
- PropertyCollection.cs
- BinHexDecoder.cs
- BrowserInteropHelper.cs
- PersistNameAttribute.cs
- activationcontext.cs
- RectKeyFrameCollection.cs
- LocalizeDesigner.cs
- AlignmentYValidation.cs
- RuntimeDelegateArgument.cs
- WorkflowMarkupSerializerMapping.cs
- Exceptions.cs
- EndEvent.cs
- KeyGestureConverter.cs
- AmbientValueAttribute.cs
- FlowStep.cs
- Token.cs
- ProtocolsConfigurationHandler.cs
- NameScopePropertyAttribute.cs
- Int16AnimationBase.cs