Answered by:
Routing

Question
-
User-10210915 posted
Hi,
Can routing be done only on a primary key? Is it possible to add routing for a non-primary key?
Thank You.
Monday, November 10, 2008 12:16 PM
Answers
-
User-330204900 posted
Routing uses PK's to uniquely identify records you can pass any parameters vis routing you just need to set that up in a route, the only issue will be getting DD to filter on the none PK parameters.
SEE:
Dynamic Data and Routes (Take 2)
and
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, November 11, 2008 3:33 AM
All replies
-
User-330204900 posted
Routing uses PK's to uniquely identify records you can pass any parameters vis routing you just need to set that up in a route, the only issue will be getting DD to filter on the none PK parameters.
SEE:
Dynamic Data and Routes (Take 2)
and
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, November 11, 2008 3:33 AM -
User-330204900 posted
<STRIKE>One caveat is that to embed parameters into the route you will need to run your live server on IIS7.</STRIKE>
Sorry [:(] that wrong its if you drop the aspx extension that things go wrong see here Re: dropping the .aspx extension in the routing rules gives me a 404
Hope this helps [:D]
Tuesday, November 11, 2008 5:04 AM -
User-10210915 posted
Hi,
I tried the following from your articles, but still does not work. Again, the column is neither a primary key nor foreign key. Note: XYZ is the column name here. Please let me know what i am missing here? Thank You.
routes.Add(new DynamicDataRoute("{table}/{action}/XYZ){
Model = model,
Table = "tablename",Constraints =
new RouteValueDictionary(new { action = "List" })});
Wednesday, November 12, 2008 11:46 AM -
User-330204900 posted
If I remember the
routes.Add(new DynamicDataRoute("{table}/{action}/XYZ)XYZ part should be more like:
routes.Add(new DynamicDataRoute("{table}/{action}/{Id})
Hope this helps [:D]
Wednesday, November 12, 2008 6:08 PM -
User-10210915 posted
Thank you for responding back.
But how will id will be related to XYZ Column? Will i need to specify that {id} is XYZ column?
Thank You in advance.
Thursday, November 13, 2008 4:35 PM -
User-330204900 posted
if your normal url would be:
Orders/Edit.aspx?XYZ=123
then your route would look like
routes.Add(new DynamicDataRoute("{table}/{action}/{XYZ})
The {} braces indicate a variable so your url could look like:
Orders/Edit/123
And you would still referance it via QueryString["XYZ"]
Hope this helps [:D]
Thursday, November 13, 2008 5:12 PM