Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.08 KB | None | 0 0
  1. .CS
  2.  
  3. protected void Page_Load(object sender, EventArgs e)
  4.         {
  5.             //Stabilisco la connessione al server
  6.             string conn = "Server=PC1319; Database=kitkits; User Id=sa; Password=1mp0ss1b1l3;";
  7.             SqlConnection con = new SqlConnection(conn);
  8.  
  9.             ////Richiamo la stored procedure
  10.             //SqlCommand cmd = new SqlCommand("Cerca_Acquisti_Cliente", con);
  11.             //cmd.CommandType = CommandType.StoredProcedure;
  12.             //cmd.Parameters.Add(new SqlParameter("@nome", "Tiberio"));
  13.             //cmd.Parameters.Add(new SqlParameter("@cognome", "Tonetti"));
  14.             //DataSet ds = new DataSet();
  15.             //SqlDataAdapter da = new SqlDataAdapter(cmd);
  16.             //da.Fill(ds, "Kit");
  17.             //GridView1.DataSource = ds.Tables["Kit"].DefaultView;
  18.             //GridView1.DataBind();
  19.  
  20.             ////Richiamo la stored procedure
  21.             //cmd = new SqlCommand("Cerca_per_prezzo", con);
  22.             //cmd.CommandType = CommandType.StoredProcedure;
  23.             //cmd.Parameters.Add(new SqlParameter("@prezzo", 150));
  24.             //ds = new DataSet();
  25.             //da = new SqlDataAdapter(cmd);
  26.             //da.Fill(ds, "Kit");
  27.             //GridView2.DataSource = ds.Tables["Kit"].DefaultView;
  28.             //GridView2.DataBind();
  29.  
  30.             if (Session["id"] == "")
  31.             {
  32.             }
  33.             else
  34.             {
  35.                 foreach (string i in (List<string>)Session["Carrello"])
  36.  
  37.                     ListBox1.Items.Add(i);
  38.  
  39.                 //    string conn = "Server=PC1319; Database=kitkits; User Id=sa; Password=1mp0ss1b1l3;";
  40.                 //SqlConnection con = new SqlConnection(conn);
  41.                 //DataSet dset = new DataSet();
  42.  
  43.  
  44.                 //    SqlCommand cmd = new SqlCommand("SELECT * FROM Acquisti JOIN Cliente ON Cliente.Id=IdCliente WHERE username='"+Session["id"]+"'", con);
  45.                 //    SqlDataAdapter da = new SqlDataAdapter(cmd);
  46.                 //    da.Fill(dset, "Carrello");
  47.  
  48.                 //    GridView1.DataSource = ((DataSet)Application["ds"]).Tables["Acquisti"].DefaultView;
  49.                 //    GridView1.DataBind();
  50.  
  51.  
  52.                 //Richiamo la stored procedure
  53.                 SqlCommand cmd = new SqlCommand("Cerca_Acquisti_Cliente", con);
  54.                 cmd.CommandType = CommandType.StoredProcedure;
  55.                 cmd.Parameters.Add(new SqlParameter("@username", Session["id"].ToString()));
  56.                 DataSet ds = new DataSet();
  57.                 SqlDataAdapter da = new SqlDataAdapter(cmd);
  58.                 da.Fill(ds, "Acquisti");
  59.                 GridView1.DataSource = ds.Tables["Acquisti"].DefaultView;
  60.                 GridView1.DataBind();
  61.             }
  62. .ASPX
  63. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
  64.     <h2 class="auto-style5"><strong>Cart</strong></h2>
  65.     <p id="idcar">
  66.         <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
  67.     </p>
  68. <p>
  69.         Acquisti recenti</p>
  70. <p>
  71.         <asp:GridView ID="GridView1" runat="server">
  72.         </asp:GridView>
  73.     </p>
  74. </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement