protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode)
            {
                return;
            }

            MetaTable table = MetaTableHelper.FindMetaTable(this, Context);

            if (table == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  DynamicDataResources.DynamicEntity_ControlNeedsToExistInAContextSupportingDynamicData,
                                                                  this.ID));
            }

            EntityTemplateFactory     entityTemplateFactory = table.Model.EntityTemplateFactory;
            EntityTemplateUserControl entityTemplateControl = entityTemplateFactory.CreateEntityTemplate(table, Mode, UIHint);

            if (entityTemplateControl == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  DynamicDataResources.DynamicEntity_CantFindTemplate,
                                                                  table.Name,
                                                                  entityTemplateFactory.TemplateFolderVirtualPath));
            }

            entityTemplateControl.Mode            = Mode;
            entityTemplateControl.ValidationGroup = ValidationGroup;
            entityTemplateControl.Table           = table;
            Controls.Add(entityTemplateControl);
        }
 /// <summary>
 /// Find the containing data control, and return the MetaTable associated with it, if any
 /// </summary>
 public static MetaTable FindMetaTable(this Control current)
 {
     return(MetaTableHelper.FindMetaTable(current, HttpContext.Current.ToWrapper()));
 }