internal static void EnableDynamicData(INamingContainer control, string entityTypeName) { if (control == null) { throw new ArgumentNullException("control"); } if (s_enableDynamicDataMethod == null) { Type dataControlExtensionsType = Assembly.Load(AssemblyRef.SystemWebDynamicData).GetType("System.Web.UI.DataControlExtensions"); s_enableDynamicDataMethod = dataControlExtensionsType.GetMethod("EnableDynamicData", BindingFlags.Public | BindingFlags.Static, binder: null, types: new Type[] { typeof(INamingContainer), typeof(Type) }, modifiers: null); } Debug.Assert(s_enableDynamicDataMethod != null); Type entityType = BuildManager.GetType(entityTypeName, throwOnError: false); if (entityType != null) { s_enableDynamicDataMethod.Invoke(obj: null, parameters: new object[] { control, entityType }); } }
public static void EnableDynamicData(this INamingContainer control, Type entityType, object defaults) { MetaTable table = GetTableFromCache(entityType); control.SetMetaTable(table, defaults); DynamicDataExtensions.ApplyFieldGenerator(control, table); }
public static void SetMetaTable(this INamingContainer control, MetaTable table, object defaultValues) { if (defaultValues == null) { throw new ArgumentNullException("defaultValues"); } SetMetaTableInternal(control, table, Misc.ConvertObjectToDictionary(defaultValues), new HttpContextWrapper(HttpContext.Current)); }
public string GetUniqueName(INamingContainer container, IDesignableControl newChild) { var type = newChild.GetType(); string namePart = type.Name; int existingCount = (from c in container.Children where c.GetType() == type select c).Count(); return(namePart + existingCount); }
internal static bool TryGetMetaTable(INamingContainer control, HttpContextBase context, out MetaTable table) { if (control == null) { throw new ArgumentNullException("control"); } table = MetaTableHelper.GetTableFromMapping(context, control); return(table != null); }
internal static MetaTable GetMetaTable(INamingContainer control, HttpContextBase context) { MetaTable table; if (!TryGetMetaTable(control, context, out table)) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.MetaTable_CannotGetTableFromControl)); } return(table); }
internal static void ApplyFieldGenerator(INamingContainer control, MetaTable table) { GridView gridView = control as GridView; if (gridView != null && gridView.AutoGenerateColumns && gridView.ColumnsGenerator == null) { gridView.ColumnsGenerator = new DefaultAutoFieldGenerator(table); } else { DetailsView detailsView = control as DetailsView; if (detailsView != null && detailsView.AutoGenerateRows && detailsView.RowsGenerator == null) { detailsView.RowsGenerator = new DefaultAutoFieldGenerator(table); } } }
internal static void SetMetaTableInternal(INamingContainer control, MetaTable table, IDictionary <string, object> defaultValues, HttpContextBase context) { if (control == null) { throw new ArgumentNullException("control"); } if (table == null) { throw new ArgumentNullException("table"); } IDataBoundControl dataBoundControl = control as IDataBoundControl; IDataSource dataSource = null; if (dataBoundControl != null) { dataSource = dataBoundControl.DataSourceObject; } MetaTableHelper.SetTableInMapping(context, control, table, defaultValues); if (dataSource != null) { // If the control being mapped is a databound control then register its datasource MetaTableHelper.SetTableInMapping(context, dataSource, table, defaultValues); } }
public static bool TryGetMetaTable(this INamingContainer control, out MetaTable table) { return(TryGetMetaTable(control, new HttpContextWrapper(HttpContext.Current), out table)); }
public static MetaTable GetMetaTable(this INamingContainer control) { return(GetMetaTable(control, new HttpContextWrapper(HttpContext.Current))); }
public static IDictionary <string, object> GetDefaultValues(this INamingContainer control) { return(GetDefaultValues(control, new HttpContextWrapper(HttpContext.Current))); }
public static void SetMetaTable(this INamingContainer control, MetaTable table) { SetMetaTableInternal(control, table, null /* defaultValues*/, new HttpContextWrapper(HttpContext.Current)); }
internal static void EnableDynamicData(INamingContainer control, string entityTypeName) { if (control == null) { throw new ArgumentNullException("control"); } if (s_enableDynamicDataMethod == null) { Type dataControlExtensionsType = Assembly.Load(AssemblyRef.SystemWebDynamicData).GetType("System.Web.UI.DataControlExtensions"); s_enableDynamicDataMethod = dataControlExtensionsType.GetMethod("EnableDynamicData", BindingFlags.Public | BindingFlags.Static, binder: null, types: new Type[] { typeof(INamingContainer), typeof(Type) }, modifiers: null); } Debug.Assert(s_enableDynamicDataMethod != null); Type entityType = BuildManager.GetType(entityTypeName, throwOnError: false); if (entityType != null) { s_enableDynamicDataMethod.Invoke(obj: null, parameters: new object[] { control, entityType }); } }