public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { System.Web.UI.Control instance = (System.Web.UI.Control) context.Instance; IServiceProvider site = instance.Site; if (site == null) { if (instance.Page != null) { site = instance.Page.Site; } if (site == null) { site = provider; } } if (site != null) { DesignerTransaction transaction = ((IDesignerHost) site.GetService(typeof(IDesignerHost))).CreateTransaction("(DataBindings)"); try { IComponentChangeService service = (IComponentChangeService) site.GetService(typeof(IComponentChangeService)); if (service != null) { try { service.OnComponentChanging(instance, null); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return value; } } DialogResult cancel = DialogResult.Cancel; try { DataBindingsDialog dialog = new DataBindingsDialog(site, instance); cancel = ((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))).ShowDialog(dialog); } finally { if ((cancel == DialogResult.OK) && (service != null)) { try { service.OnComponentChanged(instance, null, null, null); } catch { } } } } finally { transaction.Commit(); } } return value; }
private bool DataBindingsCallback(object context) { System.Web.UI.Control component = (System.Web.UI.Control) this._parent.Component; ISite serviceProvider = component.Site; DataBindingsDialog form = new DataBindingsDialog(serviceProvider, component); return (UIServiceHelper.ShowDialog(serviceProvider, form) == DialogResult.OK); }