public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     System.Web.UI.Control instance = context.Instance as System.Web.UI.Control;
     if (provider != null)
     {
         IDataEnvironment environment = (IDataEnvironment) provider.GetService(typeof(IDataEnvironment));
         if (environment != null)
         {
             IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
             if ((edSvc != null) && (context.Instance != null))
             {
                 if (this._connectionStringPicker == null)
                 {
                     this._connectionStringPicker = new ConnectionStringPicker();
                 }
                 string connectionString = (string) value;
                 ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(typeof(ConnectionStringsExpressionBuilder), provider);
                 if (expressionEditor == null)
                 {
                     return value;
                 }
                 string expressionPrefix = expressionEditor.ExpressionPrefix;
                 DesignerDataConnection currentConnection = GetCurrentConnection(instance, context.PropertyDescriptor.Name, connectionString, expressionPrefix);
                 this._connectionStringPicker.Start(edSvc, environment.Connections, currentConnection);
                 edSvc.DropDownControl(this._connectionStringPicker);
                 if (this._connectionStringPicker.SelectedItem != null)
                 {
                     DesignerDataConnection selectedConnection = this._connectionStringPicker.SelectedConnection;
                     if (selectedConnection == null)
                     {
                         selectedConnection = environment.BuildConnection(UIServiceHelper.GetDialogOwnerWindow(provider), null);
                     }
                     if (selectedConnection != null)
                     {
                         if (selectedConnection.IsConfigured)
                         {
                             ((IExpressionsAccessor) instance).Expressions.Add(new ExpressionBinding(context.PropertyDescriptor.Name, context.PropertyDescriptor.PropertyType, expressionPrefix, selectedConnection.Name));
                             this.SetProviderName(context.Instance, selectedConnection);
                             IComponentChangeService service = (IComponentChangeService) provider.GetService(typeof(IComponentChangeService));
                             if (service != null)
                             {
                                 service.OnComponentChanged(instance, null, null, null);
                             }
                         }
                         else
                         {
                             value = selectedConnection.ConnectionString;
                             this.SetProviderName(context.Instance, selectedConnection);
                         }
                     }
                 }
                 this._connectionStringPicker.End();
             }
             return value;
         }
     }
     string providerName = this.GetProviderName(context.Instance);
     ConnectionStringEditorDialog form = new ConnectionStringEditorDialog(provider, providerName) {
         ConnectionString = (string) value
     };
     if (UIServiceHelper.ShowDialog(provider, form) == DialogResult.OK)
     {
         value = form.ConnectionString;
     }
     return value;
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            System.Web.UI.Control instance = context.Instance as System.Web.UI.Control;
            if (provider != null)
            {
                IDataEnvironment environment = (IDataEnvironment)provider.GetService(typeof(IDataEnvironment));
                if (environment != null)
                {
                    IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    if ((edSvc != null) && (context.Instance != null))
                    {
                        if (this._connectionStringPicker == null)
                        {
                            this._connectionStringPicker = new ConnectionStringPicker();
                        }
                        string           connectionString = (string)value;
                        ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(typeof(ConnectionStringsExpressionBuilder), provider);
                        if (expressionEditor == null)
                        {
                            return(value);
                        }
                        string expressionPrefix = expressionEditor.ExpressionPrefix;
                        DesignerDataConnection currentConnection = GetCurrentConnection(instance, context.PropertyDescriptor.Name, connectionString, expressionPrefix);
                        this._connectionStringPicker.Start(edSvc, environment.Connections, currentConnection);
                        edSvc.DropDownControl(this._connectionStringPicker);
                        if (this._connectionStringPicker.SelectedItem != null)
                        {
                            DesignerDataConnection selectedConnection = this._connectionStringPicker.SelectedConnection;
                            if (selectedConnection == null)
                            {
                                selectedConnection = environment.BuildConnection(UIServiceHelper.GetDialogOwnerWindow(provider), null);
                            }
                            if (selectedConnection != null)
                            {
                                if (selectedConnection.IsConfigured)
                                {
                                    ((IExpressionsAccessor)instance).Expressions.Add(new ExpressionBinding(context.PropertyDescriptor.Name, context.PropertyDescriptor.PropertyType, expressionPrefix, selectedConnection.Name));
                                    this.SetProviderName(context.Instance, selectedConnection);
                                    IComponentChangeService service = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService));
                                    if (service != null)
                                    {
                                        service.OnComponentChanged(instance, null, null, null);
                                    }
                                }
                                else
                                {
                                    value = selectedConnection.ConnectionString;
                                    this.SetProviderName(context.Instance, selectedConnection);
                                }
                            }
                        }
                        this._connectionStringPicker.End();
                    }
                    return(value);
                }
            }
            string providerName = this.GetProviderName(context.Instance);
            ConnectionStringEditorDialog form = new ConnectionStringEditorDialog(provider, providerName)
            {
                ConnectionString = (string)value
            };

            if (UIServiceHelper.ShowDialog(provider, form) == DialogResult.OK)
            {
                value = form.ConnectionString;
            }
            return(value);
        }