locked
FieldTemplateUserControl.ChildrenPath RRS feed

  • Question

  • User645151313 posted

    Is there a way to control the names of querystring filter parameters returned by this property? For example if I'm displaying a list of type EntityA, which has multiple children of type EntityB the list will contain a column using the Children.ascx field template (by default). This field template will generate a hyperlink linking to an URL /EntityB/List.aspx?EntityAId=1 (or similar). I know I can override the path portion of the URL but I'm really interested in modifying the 'EntityAId' parameter name. Is this parameter name hard-wired to the foreign key member name of EntityB or can it be controlled via attributes or some other means?

    Friday, October 24, 2008 4:31 AM

Answers

  • User1641955678 posted

    (1) I'm not quite following you here.  Having a custom route should not have any bearing on whether the page template is used.  If you don't want to use the default page template for a given page, you need to create a custom page for it (under DynamicData/CustomPages/[TableName])

    (2) If your goal is to keep the foreign key filters on the query string, but have then named differently, you should be able to do this by writing the same kind of code that the Futures has in PrettyDynamicDataRoute.FixUpRouteValues.  Basically, in one direction, rename from the true FK name to your alternate name, and in the other direction, do the reverse.  I did a quick test as a proof of concept and was able to get a __ prepended to all FK names that appear in the query string.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 28, 2008 5:30 PM

All replies

  • User-330204900 posted

    Hi Matt, not entirly sure what you want to do?

    Do you wan't to modify the chilrens FK ID from the parent or is it something else?

    Friday, October 24, 2008 11:09 AM
  • User1024101778 posted

    The easiest place to change this would be the in the LINQ-to-SQL DBML.  If you change the name of the column in the dbml it will be reflected in Dynamic Data.

    Friday, October 24, 2008 11:41 AM
  • User1641955678 posted

    Another way to do this is through routing, where you could define a route where the FK gets passed on the URL instead of the query string.

    David

    Friday, October 24, 2008 3:17 PM
  • User645151313 posted

    Basically when viewing a list of Departments I might have a column that links to a page displaying Employees. The Dynamic Data control supplied for this is 'Children.ascx'. By default it returns a URL corresponding to the route defined for the 'Employees > List' action. In addition it appends to the querystring the appropriate filters. So for example if I had clicked to view the Employees of the first Department my browser might load /Employees/List.aspx?DepartmentID=1 because 'DepartmentID' is the name of the foreign key on the Employee entity.

    I would like to know if it is possible to influence the name of this filter parameter, e.g. /Employees/List.aspx?DId=1. Ideally without modifying the data model directly as this is specific to the UI layer and not the rest of the application.

    Monday, October 27, 2008 12:58 PM
  • User1641955678 posted

    Please see my previous reply.  You should be able to achieve this using a custom route.  See the Futures app for some examples of custom routes.

    thanks,
    David

    Monday, October 27, 2008 2:22 PM
  • User645151313 posted

    Thanks David, I've looked into the custom routes in the Futures App. In doing so I noticed two things:

    (1) Even if you define custom routes for all scaffolded tables you still need to include the provided page templates. Otherwise I was getting HttpExceptions saying '/DynamicData/PageTemplates/List.aspx' does not exist - even when I wasn't requesting that particular page. Does Dynamic Data do some runtime validation to ensure the default pages exist or was I doing something wrong? 

    (2) I take your point that I can include the parameters I require in the path of the URL. However, the routing system stops me from including them on the querystring because I'm not allowed '?' in route URLs. From this I conclude that the default behaviour of including the necessary filter parameters on the querystring cannot be modifed. Could you please comment on this?

    Tuesday, October 28, 2008 5:47 AM
  • User1641955678 posted

    (1) I'm not quite following you here.  Having a custom route should not have any bearing on whether the page template is used.  If you don't want to use the default page template for a given page, you need to create a custom page for it (under DynamicData/CustomPages/[TableName])

    (2) If your goal is to keep the foreign key filters on the query string, but have then named differently, you should be able to do this by writing the same kind of code that the Futures has in PrettyDynamicDataRoute.FixUpRouteValues.  Basically, in one direction, rename from the true FK name to your alternate name, and in the other direction, do the reverse.  I did a quick test as a proof of concept and was able to get a __ prepended to all FK names that appear in the query string.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 28, 2008 5:30 PM
  • User645151313 posted

    (1) I misunderstood the way Dynamic Data uses the route information.

    (2) This approach allows me to obtain the result I am after and the logic is (IMO) in the correct place - i.e. the UI layer.

    Wednesday, October 29, 2008 10:49 AM