Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebControls / FilteredDataSetHelper.cs / 1 / 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; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IRCollection.cs
- AspCompat.cs
- CodeTypeReference.cs
- WindowsGraphicsWrapper.cs
- RuntimeWrappedException.cs
- StreamedFramingRequestChannel.cs
- KnownIds.cs
- DrawListViewSubItemEventArgs.cs
- CalendarDay.cs
- Debugger.cs
- SoapEnumAttribute.cs
- ContainerSelectorBehavior.cs
- RouteCollection.cs
- SchemaNames.cs
- MessageBox.cs
- GridPatternIdentifiers.cs
- DecimalAnimationBase.cs
- IntSecurity.cs
- GlobalItem.cs
- Array.cs
- EntityDataSourceQueryBuilder.cs
- MeasureItemEvent.cs
- SchemaNamespaceManager.cs
- PackageRelationshipSelector.cs
- FormViewRow.cs
- StackSpiller.Generated.cs
- XmlIlGenerator.cs
- ManifestSignedXml.cs
- Dictionary.cs
- AssertSection.cs
- MarshalByValueComponent.cs
- DetailsViewInsertedEventArgs.cs
- WebPartMinimizeVerb.cs
- ContentElementAutomationPeer.cs
- TextTreeInsertElementUndoUnit.cs
- WMIGenerator.cs
- XmlSchemaChoice.cs
- ConfigurationValidatorAttribute.cs
- ReflectionServiceProvider.cs
- FactoryMaker.cs
- SymLanguageType.cs
- ScriptingAuthenticationServiceSection.cs
- KnownBoxes.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- BufferBuilder.cs
- ContravarianceAdapter.cs
- SizeAnimationUsingKeyFrames.cs
- Assert.cs
- SemanticAnalyzer.cs
- XmlSchemaAttributeGroupRef.cs
- FilterQuery.cs
- SchemaNamespaceManager.cs
- RedirectionProxy.cs
- Hash.cs
- ManualResetEvent.cs
- SQLSingle.cs
- HttpApplicationStateBase.cs
- PngBitmapDecoder.cs
- EnumDataContract.cs
- AlignmentXValidation.cs
- QueryRewriter.cs
- ArraySortHelper.cs
- PopupControlService.cs
- WpfMemberInvoker.cs
- IgnorePropertiesAttribute.cs
- IgnoreFileBuildProvider.cs
- CollectionViewGroupRoot.cs
- HttpPostedFile.cs
- ProfileEventArgs.cs
- TableAutomationPeer.cs
- ReadContentAsBinaryHelper.cs
- LineUtil.cs
- ToolStripDropDownClosedEventArgs.cs
- CssStyleCollection.cs
- BitmapMetadata.cs
- FlowNode.cs
- DynamicILGenerator.cs
- WebException.cs
- PlainXmlDeserializer.cs
- KernelTypeValidation.cs
- GeneralTransformGroup.cs
- ListBoxChrome.cs
- EntityCollection.cs
- JsonServiceDocumentSerializer.cs
- WeakEventManager.cs
- DataGridViewUtilities.cs
- DivideByZeroException.cs
- TextReader.cs
- SamlAttribute.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- OutputCacheProfileCollection.cs
- ControlTemplate.cs
- CommonDialog.cs
- ToolStripMenuItemDesigner.cs
- DesignTable.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- ContentElementAutomationPeer.cs
- DataExpression.cs
- MessageDroppedTraceRecord.cs
- Transform3D.cs