Advertisement
Guest User

results

a guest
Apr 27th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="results.aspx.cs" Inherits="MovieDatabase.results1" %>
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7. <title></title>
  8. </head>
  9. <body>
  10. <form id="form1" runat="server">
  11. <div>
  12. <asp:gridview ID="Gridview1" runat="server"
  13. AutoGenerateColumns="true">
  14. <Columns>
  15. </Columns>
  16. </asp:gridview>
  17. <br />
  18. <asp:Button ID="BackButton" runat="server" Text="Back to Home Page" OnClick="BackButton_Click" />
  19.  
  20. </div>
  21. </form>
  22. </body>
  23. </html>
  24.  
  25.  
  26.  
  27.  
  28.  
  29. using System;
  30. using System.Collections.Generic;
  31. using System.Configuration;
  32. using System.Data;
  33. using System.Data.OleDb;
  34. using System.Linq;
  35. using System.Web;
  36. using System.Web.UI;
  37. using System.Web.UI.WebControls;
  38.  
  39. namespace MovieDatabase
  40. {
  41. public partial class results1 : System.Web.UI.Page
  42. {
  43. protected void Page_Load(object sender, EventArgs e)
  44. {
  45. OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["MovieDatabase"].ConnectionString);
  46.  
  47. string query = ("SELECT TITLE, BUDGET, RELEASEYEAR, GENRE, ADDEDBY FROM MOVIE WHERE TITLE LIKE @title");
  48. connection.Open();
  49. OleDbCommand cmd = new OleDbCommand(query, connection);
  50. cmd.Parameters.AddWithValue("@title", "%"+Session["searchTitle"]+"%");
  51. OleDbDataReader reader = cmd.ExecuteReader();
  52.  
  53. // Response.Write("<table border=\"2\">" + "<tr>" + "<th> Title </th>" + "<th> Budget </th>" +
  54. // "<th> Release Year </th>" + "<th> Genre </th>" +
  55. // "<th> Added By </th>" + "<th> Movie ID </th>" + "<th> Make This Movie Your Favorite </th>" + "</tr>");
  56. DataTable dt = new DataTable();
  57. dt.Columns.Add(new DataColumn("Title", typeof(string)));
  58. dt.Columns.Add(new DataColumn("Budget", typeof(string)));
  59. dt.Columns.Add(new DataColumn("Release Year", typeof(string)));
  60. dt.Columns.Add(new DataColumn("Genre", typeof(string)));
  61. dt.Columns.Add(new DataColumn("Added By", typeof(string)));
  62.  
  63. while (reader.Read())
  64. {
  65. DataRow drCurrentRow = dt.NewRow();
  66. drCurrentRow["Title"] = reader["TITLE"].ToString();
  67. drCurrentRow["Budget"] = reader["BUDGET"].ToString();
  68. drCurrentRow["Release Year"] = reader["RELEASEYEAR"].ToString();
  69. drCurrentRow["Genre"] = reader["GENRE"].ToString();
  70. drCurrentRow["Added By"] = reader["ADDEDBY"].ToString();
  71. dt.Rows.Add(drCurrentRow);
  72. }
  73. Gridview1.DataSource = dt;
  74. Gridview1.DataBind();
  75.  
  76.  
  77. // Response.Write("<tr>" + "<td><i>" + reader["TITLE"] +
  78. // "<td>" + reader["BUDGET"] + "</td>" + "<td>" + reader["RELEASE YEAR"] + "</td>" +
  79. // "<td>" + reader["GENRE"] + "</td>" + "<td>" + reader["ADDED BY"] + "</td>" + "<td>" +
  80. // reader["MOVIE ID"] + "</td>" + "<td>" + "</tr>");
  81.  
  82. }
  83.  
  84. protected void BackButton_Click(object sender, EventArgs e)
  85. {
  86. Response.Redirect("Default.aspx");
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement