protected void OnButton1_Click(object sender, EventArgs e) { using (Database1Entities db = new Database1Entities()) { var query = (from a in db.Movies select a).ToList(); var result = query.Where(a => a.Title.Contains(title.Text)); GridView1.DataSource = result; GridView1.DataBind(); } }
protected void OnDeleteClick(object sender, EventArgs e) { using (Database1Entities db = new Database1Entities()) { var query = (from a in db.Movies select a).ToList(); var result = query.Where(a => a.Id == Int32.Parse( movieID.Text)).FirstOrDefault(); db.Movies.Remove(result); db.SaveChanges(); message.Text = "Movie successfully deleted!"; } }
protected void OnButton_Click(object sender, EventArgs e) { using (Database1Entities db = new Database1Entities()) { Movie movie = new Movie(); movie.Title = title.Text; movie.Format = format.SelectedValue; movie.Length = Int32.Parse(length.Text); movie.Release_Year = Int32.Parse(releaseYear.Text); movie.Rating = Int32.Parse(rating.SelectedValue); db.Movies.Add(movie); db.SaveChanges(); message.Text="Movie successfully created!"; } }