单击“添加到购物车”按钮后,如何在购物车中添加产品 [英] How do I add products in cart after clicking add to cart button

查看:86
本文介绍了单击“添加到购物车”按钮后,如何在购物车中添加产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是产品描述页面。



i创建了包含gridview的购物车页面,该页面将显示在点击添加到购物车后添加到购物车的产品的详细信息按钮



我尝试过:



this is product description page.

i have created cart page that contains gridview which will display details of products that is added to cart after clicking on the add to cart button

What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class Product_desc : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
    int id;
   // String product_name, product_detail;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["product_Id"] == null)
        {
            Response.Redirect("gold.aspx");
        }

        else
        {

            id = Convert.ToInt32(Request.QueryString["product_Id"].ToString());
            con.Open();
            SqlCommand com = con.CreateCommand();
            com.CommandType = CommandType.Text;
            com.CommandText = "select * from product_master where product_Id=" + id + " ";
            com.ExecuteNonQuery();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(com);
            da.Fill(dt);
            d1.DataSource = dt;
            d1.DataBind();
            con.Close();
        }
        }

        protected void Button1_Click(object sender, EventArgs e)
    {
        //add to cart code
        
    }
}

推荐答案

完全阅读并开始

购物车| Microsoft Docs [ ^ ]
read this completely and start
Shopping Cart | Microsoft Docs[^]


这篇关于单击“添加到购物车”按钮后,如何在购物车中添加产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆