locked
Dynamic data model “Visible Tables” count always Zero RRS feed

  • Question

  • User-127625424 posted

    I have added a new system(DB) to the existing dynamic data application. I have registered routes in global.asax . I have given scaffoldalltables to true.

    But in table navigation while giving DataSource to gridview, Visibletables count is always zero. eventhough tables count is 4.

     TestModel.RegisterContext(typeof(TestModel.CompassionEntities), new ContextConfiguration { ScaffoldAllTables = true });
            TestModel.FieldTemplateFactory = new AdvancedFieldTemplateFactory();
            routes.Add(new DynamicDataRoute("Test.{table}/ListDetails.aspx")
            {
                Action = PageAction.List,
                RouteHandler = new AdvancedDynamicDataRouteHandler(),
                ViewName = "ListDetails",
                Model = TestModel
            });
            routes.Add(new DynamicDataRoute("Test.{table}/ListDetails.aspx")
            {
                Action = PageAction.Details,
                RouteHandler = new AdvancedDynamicDataRouteHandler(),
                ViewName = "ListDetails",
                Model = TestModel
            });
    // grid data

    TestGridView.DataSource = Global.TestModel.VisibleTables; TestGridView.DataBind();
    Friday, May 30, 2014 2:55 AM

Answers

All replies

  • User-330204900 posted

    OK the Visible tables is a filtered set of the table, this is created but finding table that are scaffolded and have a valid route so there must be somthing wrong with how you have this up can you post the ALL the code from Global.asax.cs please :)

    Friday, May 30, 2014 6:28 AM
  • User-127625424 posted

    sure . Please see below code 

    public void RegisterRoutes(RouteCollection routes)
    {
    #region SAdmin Route Configuration
    S_Admin_Model.RegisterContext(typeof(SAdminModel.S_ADMIN_CONNECTION_STRING), new ContextConfiguration() { ScaffoldAllTables = true });
    S_Admin_Model.FieldTemplateFactory = new AdvancedFieldTemplateFactory();
    /** Full Permission **/
    routes.Add(new DynamicDataRoute("Admin.{table}/ListDetails.aspx")
    {
    Action = PageAction.List,
    RouteHandler = new AdvancedDynamicDataRouteHandler(),
    ViewName = "ListDetails",
    Model = S_Admin_Model
    });

    routes.Add(new DynamicDataRoute("Admin.{table}/ListDetails.aspx")
    {
    Action = PageAction.Details,
    RouteHandler = new AdvancedDynamicDataRouteHandler(),
    ViewName = "ListDetails",
    Model = S_Admin_Model
    });
    #endregion SAdmin Route Configuration

    #region STest Configuration
    STestModel.RegisterContext(typeof(STestModel.CompassionateCareEntities), new ContextConfiguration { ScaffoldAllTables = true });
    STestModel.FieldTemplateFactory = new AdvancedFieldTemplateFactory();
    routes.Add(new DynamicDataRoute("STest.{table}/ListDetails.aspx")
    {
    Action = PageAction.List,
    RouteHandler = new AdvancedDynamicDataRouteHandler(),
    ViewName = "ListDetails",
    Model = STestModel
    });
    routes.Add(new DynamicDataRoute("STest.{table}/ListDetails.aspx")
    {
    Action = PageAction.Details,
    RouteHandler = new AdvancedDynamicDataRouteHandler(),
    ViewName = "ListDetails",
    Model = STestModel
    });

    #endregion

    #region STestnew Configuration
    STestnewModel.RegisterContext(typeof(STestnewModel.CompassionateCareEntities1), new ContextConfiguration { ScaffoldAllTables = true });
    STestnewModel.FieldTemplateFactory = new AdvancedFieldTemplateFactory();
    routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
    {
    Action = PageAction.List,
    RouteHandler = new AdvancedDynamicDataRouteHandler(),
    ViewName = "ListDetails",
    Model = STestnewModel
    });
    //routes.Add(new DynamicDataRoute("STestnew.{table}/ListDetails.aspx")
    //{
    // Action = PageAction.Details,
    // RouteHandler = new AdvancedDynamicDataRouteHandler(),
    // ViewName = "ListDetails",
    // Model = STestnewModel
    //});

    #endregion


    }
    /// <summary>
    /// Application Start
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void Application_Start(object sender, EventArgs e)
    {
    RegisterRoutes(RouteTable.Routes);
    }

    Wednesday, June 4, 2014 12:31 AM
  • User-127625424 posted

    I have entered the URL directly for the table 

    http://localhost:38174/STest.Users/ListDetails.aspx 

    I got a null reference error in 

    if ((PageProperties.Filters != null) && (HttpContext.Current.Request.UrlReferrer.AbsoluteUri.EndsWith("/ListDetails.aspx")))
    {
    PageProperties.Filters = (PageProperties.Filters.PageName.Equals(table.Name)) ? PageProperties.Filters : new SearchHelper(table.Name);
    }

    but when i skipped this statement by 'Set next statement' option, i got the table displayed in page to my surprise :) .

    I believe i have missed some routing . Please assit

    Wednesday, June 4, 2014 2:04 AM
  • User-330204900 posted

    Haved you tried this with a vanilla application?

    Wednesday, June 4, 2014 4:42 AM
  • User-127625424 posted

    No . i have not tried it with that. also am not aware of wat is meant by vanilla application. regret for this. I am working on asp.net c# application (web application)

    Wednesday, June 4, 2014 5:26 AM
  • User-330204900 posted

    Vanilla application is a File New Project and add you model and do the mose basic config I.e. add you model and scaffold all columns.

    Wednesday, June 4, 2014 7:13 AM
  • User-127625424 posted

    My project is already developed with two models . one oracle and one sql. Now i need to integreate one more model(Sql) into the exisitng asp.net dynamic data web site. am i clear with my details.? :)

    I must have missed some code before giving source to gridview in tablenavigation.aspx page. Please assist me with it. 

    Wednesday, June 4, 2014 7:27 AM
  • User-330204900 posted

    OK so is the issue because you are using Two models?

    Wednesday, June 4, 2014 10:34 AM
  • User-127625424 posted

    thanks for your reply :)No. there is already a model included in it long back and it works fine. I have tried to include a new model recently and it does not show up in table navigation . but it is accesible through URL. 

    Thursday, June 5, 2014 8:42 AM
  • User-330204900 posted

    Please have a look ada David Ebbo's blog post here Using Dynamic Data with multiple databases that hould put you on the right path.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 5, 2014 6:37 PM
  • User-127625424 posted

    Hi , I have resolved the issue. I seems there is a mismatch between model name and database name which caused the problem. Now everything seems to work fine :)

    Thanks for your timely help . 

    Monday, June 9, 2014 8:10 AM
  • User-330204900 posted

    you are always welcome what was the issue was it pluralisation issue?

    Tuesday, June 10, 2014 11:14 AM
  • User-127625424 posted

    What happened is, when creating a connection string i have entered a different name. In the supported system i have entered another name. It seems like, the application was configured for role checking based on supported system name. It should match with the name which i have given during connection string 

    TestModel.RegisterContext(typeof(TestModel.CompassionEntities), new ContextConfiguration { ScaffoldAllTables = true });
    
    in the above line , CompassionEntities is the word i was refering to :) . that should match with the system name which i have configured for roles.
    
    I am little bit confusing i believe :) do i make any sense.?
    Thursday, June 12, 2014 5:05 AM
  • User-330204900 posted

    there are always issues with magic strings, not sure what security you are using as I use my own system :)

    Thursday, June 12, 2014 5:19 AM