Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / FilteredDataSetHelper.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UnicodeEncoding.cs
- activationcontext.cs
- QilBinary.cs
- ButtonBaseAdapter.cs
- PtsContext.cs
- App.cs
- PopupControlService.cs
- DataGridCaption.cs
- FontWeightConverter.cs
- SafeEventLogReadHandle.cs
- ConfigurationLocationCollection.cs
- querybuilder.cs
- AmbientValueAttribute.cs
- ControlAdapter.cs
- MetadataFile.cs
- Vector3D.cs
- AccessDataSourceView.cs
- ThreadStateException.cs
- ResourceDefaultValueAttribute.cs
- PropertyTabAttribute.cs
- Normalizer.cs
- Point3DConverter.cs
- Point3D.cs
- LockRecursionException.cs
- WorkflowQueue.cs
- ChtmlTextWriter.cs
- DataGridTablesFactory.cs
- ThreadStartException.cs
- ViewLoader.cs
- CompositeScriptReference.cs
- RoleBoolean.cs
- RadioButtonFlatAdapter.cs
- BamlRecordHelper.cs
- FormsAuthentication.cs
- TcpHostedTransportConfiguration.cs
- XsltOutput.cs
- XmlSchemaInfo.cs
- OAVariantLib.cs
- SelectedGridItemChangedEvent.cs
- EqualityComparer.cs
- _ScatterGatherBuffers.cs
- DataServiceExpressionVisitor.cs
- BaseHashHelper.cs
- ECDiffieHellmanCng.cs
- DateTimeFormatInfo.cs
- TypeConstant.cs
- EventLogPermissionEntry.cs
- Span.cs
- IdentifierCollection.cs
- Graphics.cs
- EditCommandColumn.cs
- TableRowCollection.cs
- LineProperties.cs
- DependencyObjectCodeDomSerializer.cs
- EntityKey.cs
- XamlUtilities.cs
- EntityUtil.cs
- CodeTypeMemberCollection.cs
- SizeFConverter.cs
- ObjectDataSourceStatusEventArgs.cs
- BitmapDownload.cs
- DependencyPropertyKey.cs
- RolePrincipal.cs
- CommentEmitter.cs
- InputLanguageCollection.cs
- TransformGroup.cs
- EventsTab.cs
- XmlUtf8RawTextWriter.cs
- ChtmlPageAdapter.cs
- Workspace.cs
- IisTraceWebEventProvider.cs
- LinqDataSourceDeleteEventArgs.cs
- MultiAsyncResult.cs
- SqlInfoMessageEvent.cs
- OutputCacheProfileCollection.cs
- RegistryPermission.cs
- PeerTransportSecurityElement.cs
- CodeTypeReferenceExpression.cs
- PageSetupDialog.cs
- XmlKeywords.cs
- ProcessModelSection.cs
- PeerHopCountAttribute.cs
- LinqDataSourceInsertEventArgs.cs
- CollectionsUtil.cs
- Compiler.cs
- IntMinMaxAggregationOperator.cs
- safelinkcollection.cs
- SemanticValue.cs
- ListItemParagraph.cs
- COAUTHINFO.cs
- Configuration.cs
- ItemsControlAutomationPeer.cs
- glyphs.cs
- StructuredTypeInfo.cs
- HandlerBase.cs
- DoubleIndependentAnimationStorage.cs
- TreeNodeClickEventArgs.cs
- XmlnsDefinitionAttribute.cs
- NamespaceDecl.cs
- cryptoapiTransform.cs