03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

486 x CHAPTER 13 DISPLAYING AND UPDATING DATA<br />

6. Click Next <strong>and</strong> then F<strong>in</strong>ish to f<strong>in</strong>alize the Configure Data Source wizard.<br />

7. Select the new SqlDataSource (called SqlDataSource2) <strong>in</strong> Design View <strong>and</strong> change its ID to<br />

GenresDataSource us<strong>in</strong>g the Properties Grid so it’s easier to recognize <strong>in</strong> the page.<br />

8. Switch to Markup View, locate the InsertItemTemplate for the GenreId of the DetailsView,<br />

<strong>and</strong> remove its contents (the TextBox control). At the place where you removed the TextBox, add<br />

a DropDownList by dragg<strong>in</strong>g it from the Toolbox <strong>in</strong>to Markup View. Your code looks like this:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

...<br />

<br />

9. Switch to Design View, right-click the DetailsView, <strong>and</strong> choose Edit Template Í Field[4] -<br />

GenreId, as shown <strong>in</strong> Figure 13-20. If you don’t see this menu item, you may need to click one<br />

of the rows with controls—such as the summary row—first to put the focus on the DetailsView<br />

correctly.<br />

FIGURE 13-20

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

Saved successfully!

Ooh no, something went wrong!