Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PageScaling.cs
- DesignerTransactionCloseEvent.cs
- DataPagerFieldCollection.cs
- Bezier.cs
- FillBehavior.cs
- TextBoxDesigner.cs
- ArrayEditor.cs
- basecomparevalidator.cs
- XslAst.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- DataGridViewCellEventArgs.cs
- PermissionRequestEvidence.cs
- XmlReaderDelegator.cs
- BroadcastEventHelper.cs
- DataGridHeaderBorder.cs
- FolderBrowserDialog.cs
- DebugHandleTracker.cs
- PolicyManager.cs
- TrackingLocationCollection.cs
- AutomationAttributeInfo.cs
- ISFTagAndGuidCache.cs
- VirtualDirectoryMappingCollection.cs
- WebException.cs
- SQlBooleanStorage.cs
- XmlSigningNodeWriter.cs
- ComponentResourceKey.cs
- EventLogEntry.cs
- GridItem.cs
- Itemizer.cs
- SelectedGridItemChangedEvent.cs
- WebPartUserCapability.cs
- PropertyPath.cs
- LongSumAggregationOperator.cs
- CommonDialog.cs
- NavigatingCancelEventArgs.cs
- DataServiceProviderWrapper.cs
- NameValueFileSectionHandler.cs
- DrawingGroup.cs
- DataColumnPropertyDescriptor.cs
- SqlUtil.cs
- TogglePattern.cs
- ExtendedPropertyCollection.cs
- PrimitiveXmlSerializers.cs
- WebPartTransformerAttribute.cs
- SuppressMergeCheckAttribute.cs
- SoapMessage.cs
- ColorEditor.cs
- SoapWriter.cs
- SmtpNegotiateAuthenticationModule.cs
- IDReferencePropertyAttribute.cs
- HelpKeywordAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- DependencyProperty.cs
- propertytag.cs
- ListSortDescriptionCollection.cs
- TypeExtensionSerializer.cs
- Preprocessor.cs
- DataBindingExpressionBuilder.cs
- AlphaSortedEnumConverter.cs
- Window.cs
- SqlExpressionNullability.cs
- ErasingStroke.cs
- CodeMethodInvokeExpression.cs
- XmlConverter.cs
- CompilerTypeWithParams.cs
- XmlUtil.cs
- StringConcat.cs
- EncodingStreamWrapper.cs
- Cursors.cs
- ParagraphVisual.cs
- XamlSerializer.cs
- ProxyHwnd.cs
- FieldCollectionEditor.cs
- GlyphingCache.cs
- HwndAppCommandInputProvider.cs
- DbInsertCommandTree.cs
- NetSectionGroup.cs
- SQLInt16Storage.cs
- QueryContext.cs
- FamilyMapCollection.cs
- ListViewDeleteEventArgs.cs
- MetadataExporter.cs
- CannotUnloadAppDomainException.cs
- SoapAttributeOverrides.cs
- Delegate.cs
- DecimalAnimationUsingKeyFrames.cs
- TrustSection.cs
- HttpModulesSection.cs
- SqlCachedBuffer.cs
- DelayedRegex.cs
- DisplayInformation.cs
- DesignerRegion.cs
- TrackingProfile.cs
- errorpatternmatcher.cs
- SafeNativeMethods.cs
- SmtpException.cs
- BufferedGraphics.cs
- OleStrCAMarshaler.cs
- NumberSubstitution.cs
- ReflectionHelper.cs