最好先判断session是否存在...不然又会出现未将对象引用到实例...
if (Session["txtType"] != null)
   其它判断过程

解决方案 »

  1.   

    Session["txtType"].Tostring().Trim() == "报告"
      

  2.   

    try,另同楼上的楼上,使用前先判断一下Session是否存在if (Session["txtType"].ToString()=="报告") 
    {
        this.btnshow.visible=true; 
    }另外,里面的代码是你手写的还是拷过来的,大小写有问题,自己检查一下
      

  3.   

    if (Session["txtType"] != null)
    我也觉得这样比较好
      

  4.   

    if ((string)Session["txtType"] != null)
    {
     if ((string)Session["txtType"]=="报告")
     {
         this.btnshow.visible=true;
     }
    }