I have a DD site split into multiple sections for different functions and users. For example, a Config site allows following Foreign keys and editing of data.
I have a New Request section of the site, where I would like to just display the names of the Foreign Key fields rather than a link to follow them.
I do not want to follow the example on C# bits, because this data annotation method sets it for all pages that use that table. I want view pages for one part of the site with no links and view pages for another part of the site with the links.
I am using an aspFormView. Is this possible?
I tried swapping out a couple of the aspDynamicField entries for Eval, but it just displayed the column name rather than the data field.
Hi Steve, you could apply the apply the attribute based on user role or table, I'm sure there is a way to do what you want. Just let us know exactly what you want is this by table or by user or some other condition?
Dynamic Data
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
It's not by User role or by Table. It is actually by the requesting page. I have a site that looks like this (has some custom routing):
/App/Config/ - Full access to all tablle to edit / delete / etc for users in a particular Windows Group using web.config and roles
/App/Requests/ - Limited access to a subset of tables. Can submit new requests and view the status of requests.
The same tables are accessed by both sites. But, if somebody is accessing via the Requests site, then I have a ViewRequest.aspx page that I want them to be able to view individual entries from the Request table in a FormView but with no links to the FK's
Then you must be implementing routes for this? if so just implement routes that only get to Details etc, an alternative is to have two DynamicData Folders and resolve to one with your routes for readOnly and the other for Read/write.
Yes, I am implementing routes but unless I misunderstood your reply that doesn't answer my question. The readOnly one still displays the Foreign Key columns as links (which I do not one for this particular table).
In reality my custom routes are not being used for these pages. They are just specifically named pages in /Requests/ such as ShowRequest.aspx. I then specify the TableName and Context parameters directly on the LinqData source and related controls. I
am just trying to use the Dynamic Data Controls to get a consistent display of the tables.
Sorry for not making myself clear [:$] if your using routes you could test for the route in the FieldTemplate and do the no version.
You can test for the route by getting the url and extracting the unique part of the path as your test or just do a string.contains on it to check if it's the readonly route.
Dynamic DataroutingReadOnly
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Marked as answer by steddyman on Feb 13, 2009 08:19 PM
Yes I know but you have to create a custom page to use it, and it only works with DynamicControl not DynamicFiled so I came up with this article:Disallow
Navigation on ForeignKey FieldTemplate – Dynamic Data with this you can just anotate the model and automatically get the functionality. [:D]
Dynamic DataHide Navigation
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
i have follow many of yours articles for my DD site and they are all excellent
I have a question about foreign key navigation: i need to disable foreign key navigation in the parent table.
I post below my code to explain my situation:
This are the metadata of my table Company (my "parent table"):
[Category("Support")]
public class CustomCompany
{
[DisplayName("Name")]
public object Name { get; set; }
[DisplayName("Description")]
public object Description { get; set; }
[DisplayName("Customer")]
[Filter(FilterControl = "Boolean")]
public object Customer { get; set; }
[DisplayName("D3 Group")]
[Filter(FilterControl = "Boolean")]
public object D3Group { get; set; }
[ScaffoldColumn(false)]
public EntityRe Project { get; set; }
}
and this are the metadata of my table Projects
public class CustomProgetti
{
public object ProjectID { get; set; }
[DisplayName("Name")]
[Filter(FilterControl = "AnyColumnAutocomplete")]
public object Name { get; set; }
[DisplayName("Customer")]
public object Customer { get; set; }
[DisplayName("Date Begin")]
[DisplayFormat(DataFormatString = "{0:d}")]
public object DateStart { get; set; }
[DisplayName("Date End")]
[DisplayFormat(DataFormatString = "{0:d}")]
public object DateEnd { get; set; }
[DisplayName("Active")]
[Filter(FilterControl = "Boolean")]
public object Active { get; set; }
[DisplayName("Productive")]
[Filter( Enabled = false)]
public object Billable { get; set; }
[DisplayName("Project Leader")]
[Filter(FilterControl = "Autocomplete")]
public object Resource { get; set; }
[DisplayName("Customer Company")]
public object Company { get; set; }
}
Note that Project has a foreing key to Company.
In Company list page on my site appears the column "Project" linked to Projects Table and i would like to disable it.
I need to add an attribute to the table company to disable link "View Projects".
The first allows you to disable the link per FK and the second allows you to disable the clink globally, i.e. you would disble the link to Product on every page.
Hope this helps [:D]
Dynamic Data
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Conditional display of Foreign key navigation
Feb 13, 2009 01:14 PM|LINK
I have a DD site split into multiple sections for different functions and users. For example, a Config site allows following Foreign keys and editing of data.
I have a New Request section of the site, where I would like to just display the names of the Foreign Key fields rather than a link to follow them.
I do not want to follow the example on C# bits, because this data annotation method sets it for all pages that use that table. I want view pages for one part of the site with no links and view pages for another part of the site with the links.
I am using an aspFormView. Is this possible?
I tried swapping out a couple of the aspDynamicField entries for Eval, but it just displayed the column name rather than the data field.
Thanks
Steve
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Conditional display of Foreign key navigation
Feb 13, 2009 03:38 PM|LINK
Hi Steve, you could apply the apply the attribute based on user role or table, I'm sure there is a way to do what you want. Just let us know exactly what you want is this by table or by user or some other condition?
Dynamic Data
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: Conditional display of Foreign key navigation
Feb 13, 2009 03:54 PM|LINK
Hi Steve
It's not by User role or by Table. It is actually by the requesting page. I have a site that looks like this (has some custom routing):
/App/Config/ - Full access to all tablle to edit / delete / etc for users in a particular Windows Group using web.config and roles
/App/Requests/ - Limited access to a subset of tables. Can submit new requests and view the status of requests.
The same tables are accessed by both sites. But, if somebody is accessing via the Requests site, then I have a ViewRequest.aspx page that I want them to be able to view individual entries from the Request table in a FormView but with no links to the FK's
Does that make any sense?
Thanks
Steve
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Conditional display of Foreign key navigation
Feb 13, 2009 05:07 PM|LINK
Then you must be implementing routes for this? if so just implement routes that only get to Details etc, an alternative is to have two DynamicData Folders and resolve to one with your routes for readOnly and the other for Read/write.
See: Dynamic Data Samples and look at SecureDynamicData.zip
also: Using Dynamic Data with multiple databases from David Ebbo's blog.
I think that a look at both of the above will give you what you want. [:D]
Dynamic Data Security Access Control
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: Conditional display of Foreign key navigation
Feb 13, 2009 05:15 PM|LINK
Yes, I am implementing routes but unless I misunderstood your reply that doesn't answer my question. The readOnly one still displays the Foreign Key columns as links (which I do not one for this particular table).
In reality my custom routes are not being used for these pages. They are just specifically named pages in /Requests/ such as ShowRequest.aspx. I then specify the TableName and Context parameters directly on the LinqData source and related controls. I am just trying to use the Dynamic Data Controls to get a consistent display of the tables.
My routing table looks like this:
routes.Add(new DynamicDataRoute("config/{table}/{action}.aspx"){
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),Model = model
});
// Add a route for the requests table
routes.Add(new DynamicDataRoute("requests/{table}/{action}.aspx"){
Constraints = new RouteValueDictionary(new { action = "List|Insert", table = "Requests" }),Model = model
});
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Conditional display of Foreign key navigation
Feb 13, 2009 08:09 PM|LINK
Sorry for not making myself clear [:$] if your using routes you could test for the route in the FieldTemplate and do the no version.
You can test for the route by getting the url and extracting the unique part of the path as your test or just do a string.contains on it to check if it's the readonly route.
Dynamic Data routing ReadOnly
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: Conditional display of Foreign key navigation
Feb 16, 2009 09:22 AM|LINK
I found out there is already a property on the Foreign Key field template to hide the link called AllowNavigation.
Here is a sample of how to use it:
<
asp:DynamicControl ID="DynamicControl5" DataField="SupportOwner" AllowNavigation="false" runat="server" Mode="ReadOnly" /> </td> </tr>sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Conditional display of Foreign key navigation
Feb 16, 2009 09:42 AM|LINK
Yes I know but you have to create a custom page to use it, and it only works with DynamicControl not DynamicFiled so I came up with this article:Disallow Navigation on ForeignKey FieldTemplate – Dynamic Data with this you can just anotate the model and automatically get the functionality. [:D]
Dynamic Data Hide Navigation
Always seeking an elegant solution.
Kharot
Member
22 Points
13 Posts
Re: Conditional display of Foreign key navigation
Nov 25, 2009 10:27 AM|LINK
Hi Steve
i have follow many of yours articles for my DD site and they are all excellent
I have a question about foreign key navigation: i need to disable foreign key navigation in the parent table.
I post below my code to explain my situation:
This are the metadata of my table Company (my "parent table"):
[Category("Support")] public class CustomCompany { [DisplayName("Name")] public object Name { get; set; } [DisplayName("Description")] public object Description { get; set; } [DisplayName("Customer")] [Filter(FilterControl = "Boolean")] public object Customer { get; set; } [DisplayName("D3 Group")] [Filter(FilterControl = "Boolean")] public object D3Group { get; set; } [ScaffoldColumn(false)] public EntityRe Project { get; set; } } and this are the metadata of my table Projectspublic class CustomProgetti { public object ProjectID { get; set; } [DisplayName("Name")] [Filter(FilterControl = "AnyColumnAutocomplete")] public object Name { get; set; } [DisplayName("Customer")] public object Customer { get; set; } [DisplayName("Date Begin")] [DisplayFormat(DataFormatString = "{0:d}")] public object DateStart { get; set; } [DisplayName("Date End")] [DisplayFormat(DataFormatString = "{0:d}")] public object DateEnd { get; set; } [DisplayName("Active")] [Filter(FilterControl = "Boolean")] public object Active { get; set; } [DisplayName("Productive")] [Filter( Enabled = false)] public object Billable { get; set; } [DisplayName("Project Leader")] [Filter(FilterControl = "Autocomplete")] public object Resource { get; set; } [DisplayName("Customer Company")] public object Company { get; set; } }Note that Project has a foreing key to Company.
In Company list page on my site appears the column "Project" linked to Projects Table and i would like to disable it.
I need to add an attribute to the table company to disable link "View Projects".
Thanks in advance for the help
Dynamic Data ForeignKey
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Conditional display of Foreign key navigation
Nov 25, 2009 10:40 AM|LINK
Hi , try this updated article here http://csharpbits.notaclue.net/2009/04/disallow-navigation-on-foreignkey.html or this one http://csharpbits.notaclue.net/2009/04/hiding-foreign-key-column-globally-in.html
The first allows you to disable the link per FK and the second allows you to disable the clink globally, i.e. you would disble the link to Product on every page.
Hope this helps [:D]
Dynamic Data
Always seeking an elegant solution.