public void ShowMyMovies() { SqlDataReader rdr = null; SqlCommand cmd = null; string sqlsel = ""; SqlConnection conn = UtilityClass.CreateConnection(); try { conn.Open(); sqlsel = "select * from Movies WHERE FilmCategoryId = 3 order by MovieName asc"; cmd = new SqlCommand(sqlsel, conn); rdr = cmd.ExecuteReader(); GridViewMovies.DataSource = rdr; GridViewMovies.DataBind(); } catch (Exception ex) { LabelMessages.Text = "Dette er en Exception: " + ex.Message; } finally { conn.Close(); } }
protected void submitSort_Click(object sender, EventArgs e) { int sortExpression = int.Parse(RatingExpression.SelectedValue); int ratingExpression = int.Parse(RatingDropDown.SelectedValue); DataSet Movies = new DataSet(); localMoviesWebService.MoviesWebService moviesWeb = new localMoviesWebService.MoviesWebService(); GridViewMovies.DataSource = moviesWeb.GetAllMoviesFiltered(sortExpression, ratingExpression); GridViewMovies.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string movieName = ""; if (Request.QueryString["MovieName"] != null) { movieName = Request.QueryString["MovieName"].ToString(); } if (movieName != "") { localMoviesWebService.MoviesWebService movies = new localMoviesWebService.MoviesWebService(); GridViewMovies.DataSource = movies.SearchMovie(movieName); GridViewMovies.DataBind(); } else if (!Page.IsPostBack) { PopulateGrid(); } }
//过后删除!!!!!!!!! public void LoadMovies(string newCinemaName) { //使前页面传入的电影院所播放的所有电影显示到页面 List <MOVIE_SCHEDULE> movieSchedules = new List <MOVIE_SCHEDULE>(); //movies = _cinemaBll.GetAllMoviesByCinemaName(newCinemaName); movieSchedules = _cinemaBll.GetMovies(newCinemaName); //int cinemaId = _cinemaBll.GetCinemaId(newCinemaName, newCinemaAddr); //MessageBox.Show(newCinemaName); //动态生成数据表 DataTable dt = new DataTable(); //添加列 DataColumn name = new DataColumn("name", typeof(string)); DataColumn price = new DataColumn("price", typeof(string)); DataColumn buyWebsite = new DataColumn("buyWebsite", typeof(string)); dt.Columns.Add(name); dt.Columns.Add(price); dt.Columns.Add(buyWebsite); foreach (MOVIE_SCHEDULE ms in movieSchedules) { DataRow row = dt.NewRow(); string movieName = _moviesBll.GetMovieNameById((int)ms.movie_id); row[name] = movieName; row[price] = ms.price; row[buyWebsite] = ms.book_website; dt.Rows.Add(row); } //清除已有数据 GridViewMovies.DataSource = null; GridViewMovies.DataBind(); //绑定新数据 GridViewMovies.DataSource = dt; GridViewMovies.DataBind(); }
private void PopulateGrid() { GridViewMovies.DataSource = GetData(); GridViewMovies.DataBind(); }