第一个问题:
代码是这样的:
<td><font face="宋体" size="2">【<font color="#0000ff"><% Session["UserName"] %></font>】,您当前的位置:主页&gt;&gt;会员注册</font></td>
报错:error CS1002: 应输入 ;
我晕,我这一行哪里需要一个分号啊????
还有一个问题:
程序:
DataTable dtShopCart=(DataTable)Session["dtShopCart"];
dtShopCart.Clear();
报错: System.NullReferenceException: 未将对象引用设置到对象的实例。
用断点来测,说dtShopCart未定义。怎么回事?
在Global.asax.cs里也有dtShopCart的相关定义,不知跟Global.asax.cs里这个有没有关系,我是新手,请高手帮帮小弟!
void Seesion_Start(Object sender,EventArgs e)
{
Session["UserID"]="";
Session["UserName"]="游客";
Session["UserSex"]="";
Session["UserRight"]="0";
DataTable dtShopCart=new DataTable();
DataColumn keyCol=new DataColumn("BookID",typeof(Int32));
dtShopCart.Columns.Add(keyCol);
dtShopCart.Columns.Add(new DataColumn("BookName",typeof(string)));
dtShopCart.Columns.Add(new DataColumn("BookAuthor",typeof(string)));
dtShopCart.Columns.Add(new DataColumn("PubName",typeof(string)));
dtShopCart.Columns.Add(new DataColumn("PubData",typeof(string)));
dtShopCart.Columns.Add(new DataColumn("OrigPrice",typeof(Decimal)));
dtShopCart.Columns.Add(new DataColumn("SellPrice",typeof(Decimal)));
dtShopCart.Columns.Add(new DataColumn("BuyNum",typeof(Int32)));
DataColumn[] primKeys=new DataColumn[1];
primKeys[0]=keyCol;
dtShopCart.PrimaryKey=primKeys;
Session["dtShopCart"]=dtShopCart;
}本来应该多奉上些分数的,但小弟初来乍到,实在没分了。。之前问问题太大手大脚,全给光了

解决方案 »

  1.   

    <%= Session["UserName"] % >
      

  2.   

    Session["dtShopCart"]; 没有对象
      

  3.   

    <%= Session["UserName"] % >,少个=号
      

  4.   

    慕白兄大哥!
    Session["dtShopCart"]; 没有对象  
    小弟还不是很明白,能否详细点说?顺便问下,工作换好了没?
      

  5.   

    第二个问题中,有会不会是你的EnableSessionState为false
      

  6.   

    是因为Session["dtShopCart"]=null你做个判断就好了
    if(Session["dtShopCart"]!=null)
    {
       DataTable dtShopCart=(DataTable)Session["dtShopCart"]; 
       dtShopCart.Clear(); 
    }