int userID = 1;//用户ID整个会话都要保存,默认没有登录,即为-1 //public bool isLatest;//是否显示最新评论 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.Form["movieName"] != null) { string message = Request.Form["movieName"]; //Response.Write(message); Session["MovieNameToMovieDetails"] = message; } } movieName = Convert.ToString(Session["MovieNameToMovieDetails"]); Session["MovieOnShow"] = movieName; //******************************************************************************* //注意,一定要将这两个量写在if判断的外面,否则每次点击按钮后变16-17行设置的默认值 //movieName=Session["MovieName"]; //userID=Session["UserID"]; //******************************************************************************* if (!IsPostBack) { //HyperLinkBack.NavigateUrl = "~/Main.aspx"; //得到前页面的电影名 //movieName = Convert.ToString(Session["MovieNameToDetail"]); //将电影名绑定到控件 LabelMovieName.Text = movieName; //根据电影名得到电影对象,从而获取电影详细信息 MOVIE movie = movieBll.GetMovie(movieName); LabelRank.Text = movie.rank.ToString() + "分"; LabelRankNum.Text = "已有" + movie.rank_number.ToString() + "人打分"; //跳转到buy_list //HyperLinkBuy.NavigateUrl = "~/"; //根据电影名得到电影海报的路径 // ImageMapMovie.ImageUrl = movieBll.GetPicture(movieName); string moviePicture = string.Empty; moviePicture = movieBll.GetMoviePicture(movieName); //绑定电影图片到控件 ImageMovieDetail.ImageUrl = moviePicture; //根据电影名 得到电影的详细信息 LabelMovieDetails.Text = movie.introduction; //根据电影院名得到电影院最新评论列表,默认显示最新列表 //isLatest = true; List <Comment> comment = movieBll.GetLatestComments(movieName); //CommentGridView.DataSource = comment; //CommentGridView.DataBind(); DisplayMovieComment(comment); //设置返回前页链接 } }
protected void Page_Load(object sender, EventArgs e) { movieName = (string)Session["MovieNameToMovieComment"]; userID = (int)Session["UserID"]; if (!IsPostBack) { LabelMovieName.Text = movieName; MOVIE movie = movieBll.GetMovie(movieName); LabelRank.Text = movie.rank.ToString() + "分"; LabelRankNum.Text = "已有" + movie.rank_number.ToString() + "人打分"; string moviePicture = string.Empty; moviePicture = movieBll.GetMoviePicture(movieName); //绑定电影图片到控件 ImageMovieDetail.ImageUrl = moviePicture; LabelMovieDetails.Text = movie.introduction; } }