日期:2014-05-18  浏览次数:20489 次

我又一段购物车的代码,可是商品怎么都添加不进去,也没有报错,麻烦帮我看看,我贴上代码
using System;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Security;
using System.Web.UI.HtmlControls;


public partial class fufei_money_1 : System.Web.UI.Page
{
  int AddProID;
  protected void Page_Load(object sender, EventArgs e)
  {
  int AddProID = Convert.ToInt32(Request.QueryString["id"].ToString());
  if (!IsPostBack)
  {
  //if (Request.QueryString["mode"] == "view")
  //{
  // ViewShoppingCart();
  // Caculator();
  //}
  //if (Request.QueryString["id"] != null || Request.QueryString["id"] != "")
  //{
   
  UpdateShoppingCart();
  Caculator();
  //}
  }
  }
   
  //创建购物车
  public void CreateCartTable()
  {
  int AddProID = Convert.ToInt32(Request.QueryString["id"].ToString());
  DataSet ds = new DataSet();
  DataTable newDT = new DataTable("CartTable");
  ds.Tables.Add(newDT);
  DataColumn newdc;
  newdc = new DataColumn("Goods_number", System.Type.GetType("System.String"));
  ds.Tables["CartTable"].Columns.Add(newdc);
  newdc = new DataColumn("ImgUrl", System.Type.GetType("System.String"));
  ds.Tables["CartTable"].Columns.Add(newdc);
  newdc = new DataColumn("original_price", System.Type.GetType("System.String"));
  ds.Tables["CartTable"].Columns.Add(newdc);
  newdc = new DataColumn("Present_price", System.Type.GetType("System.String"));
  ds.Tables["CartTable"].Columns.Add(newdc);
  newdc = new DataColumn("Total_Goods", System.Type.GetType("System.String"));
  newdc.DefaultValue = 1;
  ds.Tables["CartTable"].Columns.Add(newdc);
  newdc = new DataColumn("Total_Price", System.Type.GetType("System.Double"));
  ds.Tables["CartTable"].Columns.Add(newdc);
  Session["myCartTable"] = newDT;
  GridView1. DataSource = ds.Tables["CartTable"].DefaultView;
  GridView1. DataBind();
  }

  public void UpdateShoppingCart()
  {
  if (Session["myCartTable"] == null)
  {
  CreateCartTable();
  WriteShoppingCart();
  }
  else
  {
  WriteShoppingCart();
  }
  }
  //查看购物车
  public void ViewShoppingCart()
  {
  if (Session["myCartTable"] != null)
  {
  DataTable viewTable = new DataTable("nowCartTable");
  viewTable = (DataTable)Session["myCartTable"];
  GridView1.DataB