Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / SqlDataSourceQueryEditor.cs / 1 / SqlDataSourceQueryEditor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.WebControls { using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Drawing.Design; using System.Web.UI.Design.Util; using System.Web.UI.WebControls; using System.Windows.Forms; ////// The editor for SqlDataSource queries. /// internal sealed class SqlDataSourceQueryEditor : UITypeEditor { ////// Transacted change callback to invoke the Edit Query dialog. /// private bool EditQueryChangeCallback(object context) { SqlDataSource sqlDataSource = (SqlDataSource)((Pair)context).First; DataSourceOperation operation = (DataSourceOperation)((Pair)context).Second; IServiceProvider serviceProvider = sqlDataSource.Site; IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); Debug.Assert(designerHost != null, "Did not get DesignerHost service."); SqlDataSourceDesigner designer = (SqlDataSourceDesigner)designerHost.GetDesigner(sqlDataSource); ParameterCollection parameterCollection = null; string command = String.Empty; SqlDataSourceCommandType commandType = SqlDataSourceCommandType.Text; switch (operation) { case DataSourceOperation.Delete: parameterCollection = sqlDataSource.DeleteParameters; command = sqlDataSource.DeleteCommand; commandType = sqlDataSource.DeleteCommandType; break; case DataSourceOperation.Insert: parameterCollection = sqlDataSource.InsertParameters; command = sqlDataSource.InsertCommand; commandType = sqlDataSource.InsertCommandType; break; case DataSourceOperation.Select: parameterCollection = sqlDataSource.SelectParameters; command = sqlDataSource.SelectCommand; commandType = sqlDataSource.SelectCommandType; break; case DataSourceOperation.Update: parameterCollection = sqlDataSource.UpdateParameters; command = sqlDataSource.UpdateCommand; commandType = sqlDataSource.UpdateCommandType; break; } SqlDataSourceQueryEditorForm form = new SqlDataSourceQueryEditorForm(serviceProvider, designer, sqlDataSource.ProviderName, designer.ConnectionString, operation, commandType, command, parameterCollection); DialogResult result = UIServiceHelper.ShowDialog(serviceProvider, form); if (result == DialogResult.OK) { // We use the property descriptors to reset the values to // make sure we clear out any databindings or expressions that // may be set. PropertyDescriptor propDesc = null; switch (operation) { case DataSourceOperation.Delete: propDesc = TypeDescriptor.GetProperties(sqlDataSource)["DeleteCommand"]; break; case DataSourceOperation.Insert: propDesc = TypeDescriptor.GetProperties(sqlDataSource)["InsertCommand"]; break; case DataSourceOperation.Select: propDesc = TypeDescriptor.GetProperties(sqlDataSource)["SelectCommand"]; break; case DataSourceOperation.Update: propDesc = TypeDescriptor.GetProperties(sqlDataSource)["UpdateCommand"]; break; } if (propDesc != null) { propDesc.ResetValue(sqlDataSource); propDesc.SetValue(sqlDataSource, form.Command); } else { Debug.Fail("Unexpected DataSourceOperation: " + operation); } return true; } else { return false; } } ////// Launches the editor for SqlDataSource queries. /// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { ControlDesigner.InvokeTransactedChange( (IComponent)context.Instance, new TransactedChangeCallback(EditQueryChangeCallback), new Pair(context.Instance, value), SR.GetString(SR.SqlDataSourceDesigner_EditQueryTransactionDescription)); return value; } ////// Gets the editing style of the Edit method. /// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; } } } // 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
- EncryptedHeader.cs
- TimeSpanStorage.cs
- OracleDataReader.cs
- ColumnPropertiesGroup.cs
- Brush.cs
- SizeLimitedCache.cs
- Error.cs
- PolyLineSegmentFigureLogic.cs
- SchemaSetCompiler.cs
- PersonalizationState.cs
- TableItemPatternIdentifiers.cs
- PersonalizationAdministration.cs
- EmptyEnumerable.cs
- IpcClientManager.cs
- EntityContainerAssociationSet.cs
- BatchParser.cs
- HelpEvent.cs
- StickyNoteAnnotations.cs
- SerialPort.cs
- invalidudtexception.cs
- ContextBase.cs
- AuthenticationServiceManager.cs
- CacheChildrenQuery.cs
- PointCollection.cs
- CustomPopupPlacement.cs
- fixedPageContentExtractor.cs
- TreeNode.cs
- WebColorConverter.cs
- XmlResolver.cs
- Point3DAnimationBase.cs
- _NetRes.cs
- QilDataSource.cs
- EmptyQuery.cs
- FileDialog.cs
- Pair.cs
- RayMeshGeometry3DHitTestResult.cs
- CellQuery.cs
- ExtractedStateEntry.cs
- Overlapped.cs
- PingReply.cs
- DrawTreeNodeEventArgs.cs
- BasicExpressionVisitor.cs
- MimeObjectFactory.cs
- Condition.cs
- DelegatingConfigHost.cs
- TextModifierScope.cs
- ReflectionUtil.cs
- BitmapEffectrendercontext.cs
- FontInfo.cs
- PerformanceCounterManager.cs
- ObjectDataSourceView.cs
- ContextStaticAttribute.cs
- NativeMethods.cs
- BulletedListEventArgs.cs
- InternalControlCollection.cs
- BooleanSwitch.cs
- TextPattern.cs
- _SSPIWrapper.cs
- StrongNameUtility.cs
- WindowsIdentity.cs
- Propagator.Evaluator.cs
- HttpInputStream.cs
- BamlCollectionHolder.cs
- CommonRemoteMemoryBlock.cs
- ShaderEffect.cs
- ServiceReference.cs
- ExpressionBuilder.cs
- DataContractJsonSerializerOperationFormatter.cs
- StyleCollection.cs
- SystemIcmpV6Statistics.cs
- WindowsGraphicsWrapper.cs
- LinqDataSourceUpdateEventArgs.cs
- OperatingSystem.cs
- UnicodeEncoding.cs
- AspNetHostingPermission.cs
- WindowsNonControl.cs
- ColorAnimationBase.cs
- ILGenerator.cs
- ModelPerspective.cs
- RightsManagementEncryptedStream.cs
- ValidatorCollection.cs
- ObjectNavigationPropertyMapping.cs
- XmlReturnWriter.cs
- StaticExtensionConverter.cs
- HitTestWithGeometryDrawingContextWalker.cs
- ReflectTypeDescriptionProvider.cs
- SoapHeaderAttribute.cs
- GridPatternIdentifiers.cs
- isolationinterop.cs
- SystemWebCachingSectionGroup.cs
- OperationGenerator.cs
- ValueChangedEventManager.cs
- WindowsContainer.cs
- TripleDESCryptoServiceProvider.cs
- _SslState.cs
- PolyQuadraticBezierSegment.cs
- LinkClickEvent.cs
- PropertyOverridesTypeEditor.cs
- KnownBoxes.cs
- FlagsAttribute.cs