Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6226761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:05:32+00:00 2026-05-24T09:05:32+00:00

I’d like to use ASP.NET Dynamic Data 4.0 with an EF POCO ObjectContext as

  • 0

I’d like to use ASP.NET Dynamic Data 4.0 with an EF POCO ObjectContext as a simple entity administration console for system administrators (I’m contemplating abandoning this technology…).

I’ve got insert/update working.

I’ve figured out how to add filters for extra data types (because the built in ones are useless). I can’t figure out how to make the QueryableFilterRepeater expose my columns as filtering. I can’t added FilterUIHints to all applicable types, so that’s not an acceptable solution. I do want to leverage the built in Entity Framework Metadata Model Provider. I don’t want to write my own. The problem seems to boil down to the fact that the QueryableFilterIterator is calling MetaTable.GetFilteredColumns() and it’s only returning bool/int/DateTime columns (which is useless).

I checked out ASP.NET Dynamic Data Filtering (http://dynamicdatafiltering.codeplex.com/), but it doesn’t seem to be maintained for 4.0.

I guess I have two questions:

  1. Is there a way to do this (get my columns as filterable)?
  2. Is Dynamic Data actually suitable to use in the real world?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:05:33+00:00Added an answer on May 24, 2026 at 9:05 am

    Got frustrated and took the direct route. If there’s not a better solution to this…well, then Microsoft did a really poor job at this:

    public class QueryableFilterRepeater : System.Web.DynamicData.QueryableFilterRepeater
        {
            private static readonly FieldInfo FiltersField = typeof(System.Web.DynamicData.QueryableFilterRepeater).GetField("_filters", BindingFlags.Instance | BindingFlags.NonPublic);
            private static readonly FieldInfo DataSourceField = typeof(System.Web.DynamicData.QueryableFilterRepeater).GetField("_dataSource", BindingFlags.Instance | BindingFlags.NonPublic);
            private static readonly MethodInfo FilterInitializeMethod = typeof(DynamicFilter).GetMethod("Initialize", BindingFlags.Instance | BindingFlags.NonPublic);
            private static readonly PropertyInfo FilterContextProperty = typeof(DynamicFilter).GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
            private static readonly MethodInfo PageInitCompleteMethod = typeof(System.Web.DynamicData.QueryableFilterRepeater).GetMethod("Page_InitComplete", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
            private static readonly EventInfo InitCompleteEvent = typeof(Page).GetEvent("InitComplete");
    
            private readonly List<DynamicFilter> filters;
            private int filterCount;
            private bool initialized;
    
            public IEnumerable<DynamicFilter> Filters
            {
                get { return filters; }
            }
    
            public QueryableFilterRepeater()
            {
                filters = (List<DynamicFilter>)FiltersField.GetValue(this);
            }
    
            private IQueryableDataSource DataSource
            {
                get { return DataSourceField.GetValue(this) as IQueryableDataSource; }
            }
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
    
                InitCompleteEvent.RemoveEventHandler(Page, Delegate.CreateDelegate(typeof(EventHandler), this, PageInitCompleteMethod));
    
                Page.InitComplete += new EventHandler(Page_InitComplete);
            }
    
            protected override void OnLoad(EventArgs e)
            {
                filters.Select((f, i) => new { f, i }).Where(x => x.i > filterCount - 1).ToList().ForEach(x => filters.Remove(x.f));
                Controls.OfType<Control>().Select((c, i) => new { c, i }).Where(x => x.i > filterCount - 1).ToList().ForEach(x => Controls.Remove(x.c));
                base.OnLoad(e);
            }
    
            private void Page_InitComplete(object sender, EventArgs e)
            {
                if (!initialized)
                {
                    Controls.Clear();
                    filters.Clear();
    
                    MetaTable metaTable = DataSource.GetMetaTable();
                    int num = 0;
                    foreach (MetaColumn column in metaTable.Columns)
                    {
                        string filterUIHint = GetFilterUIHint(column);
                        if (filterUIHint == null) continue;
    
                        var filterRepeaterItem = new FilterRepeaterItem();
                        filterRepeaterItem.DataItemIndex = num;
                        filterRepeaterItem.DisplayIndex = num;
                        FilterRepeaterItem container = filterRepeaterItem;
                        num++;
                        ItemTemplate.InstantiateIn(container);
                        Controls.Add(container);
                        var dynamicFilter = container.FindControl(DynamicFilterContainerId) as DynamicFilter;
                        if (dynamicFilter == null)
                        {
                            throw new InvalidOperationException();
                        }
                        FilterContextProperty.SetValue(dynamicFilter, new HttpContextWrapper(Context), null);
                        dynamicFilter.DataField = column.Name;
                        container.DataItem = column;
                        container.DataBind();
                        container.DataItem = null;
    
                        dynamicFilter.FilterUIHint = filterUIHint;
                        filters.Add(dynamicFilter);
                        filterCount++;
                    }
                    filters.ForEach(f => FilterInitializeMethod.Invoke(f, new[] { DataSource }));
                    initialized = true;
                }
            }
    
            private string GetFilterUIHint(MetaColumn column)
            {
                if (GetUnderlyingType(column.ColumnType) == typeof(string))
                {
                    return "String";
                }
                if (GetUnderlyingType(column.ColumnType) == typeof(bool))
                {
                    return "Boolean";
                }
                if (GetUnderlyingType(column.ColumnType).IsEnum)
                {
                    return "Enumeration";
                }
                if (GetUnderlyingType(column.ColumnType) == typeof(DateTime))
                {
                    return "DateTime";
                }
                if (column is MetaForeignKeyColumn)
                {
                    return "ForeignKey";
                }
                if (column is MetaChildrenColumn)
                {
                    return "Children";
                }
    
                return null;
            }
    
            private Type GetUnderlyingType(Type type)
            {
                return Nullable.GetUnderlyingType(type) ?? type;
            }
    
            // Nested Types
    
            #region Nested type: FilterRepeaterItem
    
            private class FilterRepeaterItem : Control, IDataItemContainer
            {
                // Properties
    
                #region IDataItemContainer Members
    
                public object DataItem { get; internal set; }
                public int DataItemIndex { get; internal set; }
                public int DisplayIndex { get; internal set; }
    
                #endregion
            }
    
            #endregion
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.