Code:
/ FX-1434 / FX-1434 / 1.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
- _IPv4Address.cs
- GeometryModel3D.cs
- RepeaterDesigner.cs
- MimePart.cs
- UnknownBitmapEncoder.cs
- NegatedCellConstant.cs
- ToolStripProgressBar.cs
- ISO2022Encoding.cs
- HwndSubclass.cs
- Site.cs
- QilTypeChecker.cs
- MembershipUser.cs
- ExtenderProvidedPropertyAttribute.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- TemplateParser.cs
- SqlParameterCollection.cs
- StaticDataManager.cs
- SQLDecimal.cs
- DefinitionUpdate.cs
- SchemaInfo.cs
- Transform3D.cs
- ElementProxy.cs
- CDSsyncETWBCLProvider.cs
- QilStrConcatenator.cs
- SRGSCompiler.cs
- LocatorPartList.cs
- AsyncContentLoadedEventArgs.cs
- RestHandler.cs
- MachineKeySection.cs
- GlyphCache.cs
- FirewallWrapper.cs
- PerformanceCounterLib.cs
- PolicyStatement.cs
- StaticExtensionConverter.cs
- DBParameter.cs
- MSAANativeProvider.cs
- LongValidatorAttribute.cs
- ListenerElementsCollection.cs
- MaskDesignerDialog.cs
- OpenTypeLayout.cs
- UnsignedPublishLicense.cs
- SiteMapDataSourceView.cs
- TextTreeInsertUndoUnit.cs
- MasterPageBuildProvider.cs
- Misc.cs
- HtmlListAdapter.cs
- EventsTab.cs
- XamlStyleSerializer.cs
- FormViewUpdatedEventArgs.cs
- ToolStripScrollButton.cs
- StyleTypedPropertyAttribute.cs
- IOException.cs
- SystemIcmpV4Statistics.cs
- activationcontext.cs
- WorkflowRuntimeElement.cs
- sitestring.cs
- RegexReplacement.cs
- XmlSchemaType.cs
- XMLSchema.cs
- DebugInfoGenerator.cs
- FormatControl.cs
- TextBlockAutomationPeer.cs
- OleDbMetaDataFactory.cs
- EventBuilder.cs
- basecomparevalidator.cs
- HierarchicalDataSourceControl.cs
- ParseElementCollection.cs
- Translator.cs
- CodeBlockBuilder.cs
- WindowsAuthenticationEventArgs.cs
- wgx_sdk_version.cs
- UserControl.cs
- SQLMembershipProvider.cs
- Point4DValueSerializer.cs
- OleDbCommand.cs
- Timeline.cs
- EventLogger.cs
- VisualBasicDesignerHelper.cs
- odbcmetadatafactory.cs
- PersonalizationStateInfoCollection.cs
- SystemEvents.cs
- CodeDomSerializationProvider.cs
- XmlQueryCardinality.cs
- ColorConvertedBitmap.cs
- ObjectDataSource.cs
- MethodCallTranslator.cs
- LinqDataSourceInsertEventArgs.cs
- WindowsRebar.cs
- Image.cs
- SchemaMapping.cs
- EventArgs.cs
- ProvidePropertyAttribute.cs
- Misc.cs
- FocusManager.cs
- WmlSelectionListAdapter.cs
- LocatorPartList.cs
- DataBindingCollection.cs
- ProfileManager.cs
- DEREncoding.cs
- DataGridLinkButton.cs