Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .CS
- protected void Page_Load(object sender, EventArgs e)
- {
- //Stabilisco la connessione al server
- string conn = "Server=PC1319; Database=kitkits; User Id=sa; Password=1mp0ss1b1l3;";
- SqlConnection con = new SqlConnection(conn);
- ////Richiamo la stored procedure
- //SqlCommand cmd = new SqlCommand("Cerca_Acquisti_Cliente", con);
- //cmd.CommandType = CommandType.StoredProcedure;
- //cmd.Parameters.Add(new SqlParameter("@nome", "Tiberio"));
- //cmd.Parameters.Add(new SqlParameter("@cognome", "Tonetti"));
- //DataSet ds = new DataSet();
- //SqlDataAdapter da = new SqlDataAdapter(cmd);
- //da.Fill(ds, "Kit");
- //GridView1.DataSource = ds.Tables["Kit"].DefaultView;
- //GridView1.DataBind();
- ////Richiamo la stored procedure
- //cmd = new SqlCommand("Cerca_per_prezzo", con);
- //cmd.CommandType = CommandType.StoredProcedure;
- //cmd.Parameters.Add(new SqlParameter("@prezzo", 150));
- //ds = new DataSet();
- //da = new SqlDataAdapter(cmd);
- //da.Fill(ds, "Kit");
- //GridView2.DataSource = ds.Tables["Kit"].DefaultView;
- //GridView2.DataBind();
- if (Session["id"] == "")
- {
- }
- else
- {
- foreach (string i in (List<string>)Session["Carrello"])
- ListBox1.Items.Add(i);
- // string conn = "Server=PC1319; Database=kitkits; User Id=sa; Password=1mp0ss1b1l3;";
- //SqlConnection con = new SqlConnection(conn);
- //DataSet dset = new DataSet();
- // SqlCommand cmd = new SqlCommand("SELECT * FROM Acquisti JOIN Cliente ON Cliente.Id=IdCliente WHERE username='"+Session["id"]+"'", con);
- // SqlDataAdapter da = new SqlDataAdapter(cmd);
- // da.Fill(dset, "Carrello");
- // GridView1.DataSource = ((DataSet)Application["ds"]).Tables["Acquisti"].DefaultView;
- // GridView1.DataBind();
- //Richiamo la stored procedure
- SqlCommand cmd = new SqlCommand("Cerca_Acquisti_Cliente", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.Add(new SqlParameter("@username", Session["id"].ToString()));
- DataSet ds = new DataSet();
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.Fill(ds, "Acquisti");
- GridView1.DataSource = ds.Tables["Acquisti"].DefaultView;
- GridView1.DataBind();
- }
- .ASPX
- <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
- <h2 class="auto-style5"><strong>Cart</strong></h2>
- <p id="idcar">
- <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
- </p>
- <p>
- Acquisti recenti</p>
- <p>
- <asp:GridView ID="GridView1" runat="server">
- </asp:GridView>
- </p>
- </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement