private void EnsureInit(IQueryableDataSource dataSource)
        {
            if (_filterUserControl == null)
            {
                MetaTable table = DynamicDataExtensions.GetMetaTable(dataSource, Context);
                Column             = table.GetColumn(DataField);
                _filterUserControl = _filterLoader(Column, FilterUIHint);
                _filterUserControl.Initialize(Column, dataSource, Context);

                _filterUserControl.FilterChanged += new EventHandler(Child_FilterChanged);

                Controls.Add(_filterUserControl);
            }
        }
Ejemplo n.º 2
0
        internal void Page_InitComplete(object sender, EventArgs e)
        {
            if (_initialized)
            {
                return;
            }

            Debug.Assert(_dataSource != null);

            MetaTable table     = DynamicDataExtensions.GetMetaTable(_dataSource, Context);
            int       itemIndex = 0;

            foreach (MetaColumn column in table.GetFilteredColumns())
            {
                FilterRepeaterItem item = new FilterRepeaterItem()
                {
                    DataItemIndex = itemIndex, DisplayIndex = itemIndex
                };
                itemIndex++;
                ItemTemplate.InstantiateIn(item);
                Controls.Add(item);

                DynamicFilter filter = item.FindControl(DynamicFilterContainerId) as DynamicFilter;
                if (filter == null)
                {
                    throw new InvalidOperationException(
                              String.Format(CultureInfo.CurrentCulture,
                                            DynamicDataResources.FilterRepeater_CouldNotFindControlInTemplate,
                                            ID,
                                            typeof(QueryableFilterUserControl).FullName,
                                            DynamicFilterContainerId));
                }
                filter.Context   = Context; // needed for unit testing
                filter.DataField = column.Name;

                item.DataItem = column;
                item.DataBind();
                item.DataItem = null;

                // Keep track of all the filters we create
                _filters.Add(filter);
            }

            _filters.ForEach(f => f.Initialize(_dataSource));
            _initialized = true;
        }