Completing a Simple Storefront with LINQ
(Page 1 of 4 )
In the last article, we created the storefront's home page, which displayed the three latest products. To do this, we used LINQ in the code-behind file, manually databinding a ListView with the results. We also started to create the
Product.aspx page, which displays more detailed information about a given product. In this article, we'll finish the storefront by completing the
Product.aspx page and creating the
Browse.aspx page, which will allow the user to browse products by category.
In the first article of this series, we laid out the plans for a very simple storefront for the Adventure Works Cycles sample database that would demonstrate the use of LINQ in ASP.NET Websites. We created a master page for the entire site and put together a stylesheet for the site. We also examined the relevant tables in the database, and we created a page that would display a product's image, given the product's ProductID.
Creating the Product View Page
With the database setup, we can now begin creating the product view page, Product.aspx. This page should accept a ProductID in the query string and then display information about that product, including the product's description, which we set up our Website to handle in the last article.
Additionally, it would be wise to make sure that the ProductID is set in the query string, and that the given ProductID matches an entry in the database. This is similar to what we did with ProductPicture.aspx, except now we can display an error message rather than just have the page output nothing. This can be handled through a MultiView control. Inside the MultiView, one View can be a simple error message, alerting the user that the ProductID is invalid. The other View, then, can display the chosen product's information.
Next: Markup >>
More .NET Articles
More By Peyton McCullough