Databases Reference
In-Depth Information
DynamicDataRoute
during the application startup. Here is an example of the route registra-
tion code you normally find in the
Global.asax
:
RouteTable.Routes.Add(new DynamicDataRoute(“{table}/{action}.aspx”));
The static
Routes
property of the
RouteTable
class provides access to the global collection
of
Route
objects. This code uses it to register a new
DynamicDataRoute
that defines a URL
as a combination of a table name and a page action. The
{table}
marker defines the place
where you expect to find a table name in the URL, and the
{action}
marks the place
where you expect to find the page action. If an incoming request has a URL in this
format, the default
MetaModel
of the web application contains a table with the matching
name, and a page template exists matching the action, Dynamic Data uses this page
template to handle the request. In the following URL,
Products
matches the table parame-
ter, and
List
matches the action:
http://localhost/Products/List.aspx
Details Page Template
The Details page template generates web pages that display a single entity instance in a
form view. Figure 6.2 shows an example of such page generated for the Product entity.
Notice the URL in the address bar of the web browser; it includes the name of the table
(Products) and a query string that specifies value of the entity's primary key (ProductID
)
.
The Details page template uses this information to retrieve the appropriate entity instance
from the database.
FIGURE 6.2
Web page generated by the Details page template.