Databases Reference
In-Depth Information
This page, Default.aspx, uses
GridView
and
DynamicHyperLink
controls to display the list
of all visible tables in the data model. Clicking a table link on the Default.aspx page opens
a web page similar to that shown in Figure 1.20. Notice the URL in the address bar of the
web browser:
http://localhost/Products/List.aspx.
As discussed previously, this is a
virtual
URL. There is no physical Products folder in this
sample project. Instead, ASP.NET used the
DynamicDataRoute
configured in the Global.asax
to pass the HTTP request to the List.aspx in the
DynamicData/PageTemplates
folder.
FIGURE 1.20
Web page produced by the List page template.
The List page template is similar to the web pages built from scratch earlier in this
chapter. It also includes a
EntityDataSource
and a
GridView
controls but configures them
slightly differently, as shown here:
protected MetaTable table;
protected void Page_Init(object sender, EventArgs e)
{
this.table = DynamicDataRouteHandler.GetRequestMetaTable(this.Context);
this.gridView.SetMetaTable(this.table,
this.table.GetColumnValuesFromRoute(this.Context));
this.dataSource.EntityTypeFilter = this.table.EntityType.Name;
}