コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["HotelID"] != null)
        {
            List <Hotel> hotels = new List <Hotel>();
            //get the hotel from the database using hotel id
            Hotel h = HotelDB.getHotelByID(Session["HotelID"].ToString());
            hotels.Add(h);                       //add the account to the hotel list
            lvAccommodation.DataSource = hotels; //add the hotel list to list view data source
            lvAccommodation.DataBind();          //bind the list view data

            //retrieve all the feedback available for an hotel from the database and store them in a list
            List <Review> rvList = ReviewDB.getAllHotelReviewByID(Convert.ToInt32(Session["HotelID"]));
            AcmReviews.DataSource = rvList; //add the datasource to the grid view
            AcmReviews.DataBind();          // bind the grid view data
            if (rvList.Count == 0)          //checking whether there is a feedback availble for that hotel
            {
                lblOutput.Text = "No feedback available for this hotel";
            }
        }
        else
        {
            Response.Redirect("HomePage.aspx"); //transfer the page to view hotel
        }
    }