Description: The ReviewList user control displays a list of reviews written by customers about a specified product. It is registered and used on the Adventure Works Cycles ProductDetails page.
Implementation Notes: The ReviewList user control logic is encapsulated entirely within its Page_Load event handler. This event handler is called when a page containing the user control is accessed by a browser client.
Page_Load Event Handler: The ReviewList user control exposes a single public field -- ProductID -- at the top of the file. This enables consumers of the ReviewList user control -- like the ProductDetails.aspx page -- to either programmatically or declaratively (via a tag attribute) set the ProductID of the product to obtain a review list. Note that only those fields, properties and methods that have a "public" accessor declaration before them can be externally accessed in this way (for example: the Page_Load event handler does not have a "public" keyword accessor before it -- and as such can not be called from the ProductDetails.aspx page).
The ReviewList's Page_Load event handler utilizes the ProductID argument to invoke the "GetReviews" method of the ProductsDB class to obtain a collection of reviews by users of the specified product. This method internally uses the "usp_ReviewsList" stored procedure to fetch the review information from the Adventure Works Cycles database.
The review collection is displayed using a templated <asp:datalist> server control. The <asp:datalist> server control contains a single user-defined customization templates: an "ItemTemplate" that defines what each item in the list should look like.
The data values returned from the ProductsDB.GetReviews() method are populated into the <asp:datalist> by setting the DataList's "Datasource" property and then calling its "DataBind()" method. The DataList will iterate over every row in the DataSource when the "DataBind()" method is called -- using an ItemTemplate to customize each row's appearance.
Peformance Notes: