using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Globalization;

/* =====================================================================

  File:      _ReviewList.ascx.cs for Adventure Works Cycles Storefront Sample
  Summary:   User control which displays the list of reviews for the current product.  Embeds in the product details page.
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */

namespace Microsoft.Samples.SqlServer {

    public partial  class ReviewListControl : System.Web.UI.UserControl {

        public int ProductID;

        /// <summary>
//         protected ReviewListControl() {
//             this.Init += new System.EventHandler(Page_Init);
//         }

        //*******************************************************
        //
        // The Page_Load event on this user control is used to obtain
        // from a database a list of reviews about a specified
        // product and then databind it to an asp:datalist control.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e) {

            // Obtain and databind a list of all reviews of a product
            ReviewsDB productReviews = new ReviewsDB();
        
            MyList.DataSource = productReviews.GetReviews(ProductID);
            MyList.DataBind();

            // Update navigation link for users to add a new review
            AddReview.NavigateUrl = "ReviewAdd.aspx?productID=" + ProductID.ToString(CultureInfo.InvariantCulture);
        }

        private void Page_Init(object sender, EventArgs e) {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
        }

		#region Web Form Designer generated code
        ///		Required method for Designer support - do not modify
        ///		the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent() {
        }
		#endregion
    }
}