protected void Page_Load(object sender, EventArgs e) { //redirect to home if there is no querystring if (string.IsNullOrWhiteSpace(Request.QueryString["queryName"])) { Response.Redirect("~/"); } else { //example of the DataAccessLayer being useful: here we work with the data directly from the source instead of depending on the webcontrol(repeater in this case) // and possibly having logic fail if we decided to change to a gridview ect. we just ask the table we also use for datasource for shit directly. DataAccessLayer.MovieDBListDataTable results = FourthProjectLogic.Movie.MovieTableAdapter.GetMovieBySearchTitle(Request.QueryString["queryName"]); Repeater2.DataSource = results; Repeater2.DataBind(); if (results.Count == 1) { //redirect to single view if we only get one result Response.Redirect("~/SingleView/?queryID=" + results.Rows[0][0]); } else if (results.Count == 0) { label_noresultsmessage.Visible = true; } } }
public Movie(int ID) //constructor via DataSet - essentially the same as searching for movie by id but better aspect { DataAccessLayer.MovieDBListDataTable movieDBListRows = MovieTableAdapter.GetDataByID(ID); this.id = Int32.Parse(movieDBListRows[0]["id"].ToString()); this.title = movieDBListRows[0]["title"].ToString(); this.genre = movieDBListRows[0]["genre"].ToString(); this.year = Int32.Parse(movieDBListRows[0]["year"].ToString()); this.viewcount = Int32.Parse(movieDBListRows[0]["viewcount"].ToString()); this.posterpath = movieDBListRows[0]["posterpath"].ToString(); }