15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dynamic Data ❘ 1255<br />

This page is generated from templates, which are stored in the code for the site <strong>and</strong> are discussed in the<br />

next section. You can use the links on this page to inspect, edit, insert, <strong>and</strong> delete records, as well as to<br />

traverse associations between tables. The View Orders link for each customer will display any orders for<br />

that particular customer — on a page that includes a drop - down list of customers that you can use to view<br />

orders for different customers if you want to.<br />

If you click on Edit for a customer, you will see an edit customer view as shown in Figure 42 - 6.<br />

figure 42-6<br />

The template system used by a dynamic data web site enables you to customize what is shown for each<br />

column in a table according to what data type it is. Or you can make further customizations that are unique<br />

to columns that you specify; you really do have a lot of fl exibility here.<br />

The ID values used in the MagicShop.mdf database are stored as integer values. It is<br />

also common for databases to use GUID ID values (using the uniqueidentifier<br />

SQL type). These are currently not h<strong>and</strong>led perfectly by dynamic data web sites <strong>and</strong>,<br />

although workarounds are possible, there is currently no ideal solution.<br />

What you have seen in this section is that, even with the default settings, dynamic data can get you up <strong>and</strong><br />

running very quickly. Now, you may think that this ease of use comes at a cost, namely fl exibility. In fact,<br />

this is not the case. Using some very simple techniques, you can completely customize how dynamic data<br />

web sites work, as you will see in the next section.<br />

Customizing dynamic data Web sites<br />

There are a number of ways in which you can customize dynamic data web sites to get exactly the effect you<br />

want. These range from simply modifying the HTML <strong>and</strong> CSS for the templates to customizing the way in<br />

which data is rendered though code <strong>and</strong> attribute modifi cations. In this section, you ’ ll look at a few of these,<br />

starting with how to customize scaffolding — which, among other things, can affect the visibility<br />

of primary key values as noted in the previous section.<br />

Controlling scaffolding<br />

In the sample dynamic data web sites you have seen so far in this chapter, scaffolding was confi gured<br />

automatically for all tables (<strong>and</strong> all columns of those tables). This was achieved by setting the<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!