29.05.2015 Views

o_19mgorv9t13a3ko71fev19l81mqa.pdf

Create successful ePaper yourself

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

Figure 11-3. Rendering the scaffold List view<br />

The scaffold view makes a reasonable attempt at setting up a sensible baseline for the view. I have columns for each of the<br />

properties in the Product class and links for the other CRUD operations that target action methods in the Admin controller<br />

(although, since I created that controller without using scaffolding, the action methods do not exist).<br />

The scaffolding is clever, but the views that it generates are bland and so general as to be worthless in a project of any<br />

complexity. My advice is to start with empty controllers, views and layouts and add the functionality you need as and when you<br />

need it.<br />

Returning to the do-it-yourself approach, edit the Index.cshtml file so that it corresponds to Listing 11-4.<br />

Listing 11-4. Modifying the Index.cshtml View<br />

@model IEnumerable<br />

@{<br />

ViewBag.Title = "Admin: All Products";<br />

Layout = "∼/Views/Shared/_AdminLayout.cshtml";<br />

278

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

Saved successfully!

Ooh no, something went wrong!