BindEmergGridData(Convert.ToInt32(Session["System.RoleId"].ToString()))未将对象引用设置到对象的实例。什么原因啊??望指教~~是不是要用三元判断符判断下啊??

解决方案 »

  1.   

    冒泡Session["System.RoleId"]为null?
      

  2.   

    if(Session["System.RoleId"] != null)   //需要做这个判断
    {
        BindEmergGridData(Convert.ToInt32(Session["System.RoleId"].ToString()))
    }
      

  3.   

    Session["System.RoleId"].ToString()值为null
    你加个判断就行了
    if(! String.IsNullOrEmpty(Session["System.RoleId"].ToString()))
    {
       BindEmergGridData(Convert.ToInt32(Session["System.RoleId"].ToString())) }
      

  4.   

    BindEmergGridData(Session["System.RoleId"]==null?"":Convert.ToInt32(Sessio["System.RoleId"].ToString()))为什么不行啊??
      

  5.   

    用:
    if(Session["System.RoleId"] != null)  
    {
        BindEmergGridData(Convert.ToInt32(Session["System.RoleId"].ToString()))

    如果Session["System.RoleId"]为null,那么就不执行BindEmergGridData();
    如果用:
    BindEmergGridData(Session["System.RoleId"]==null?"":Convert.ToInt32(Sessio["System.RoleId"].ToString()))
    可能会这么执行:
    BindEmergGridData("");
      

  6.   

    但我就要他一开始的时候执行BindEmergGridData("");
    BindEmergGridData(Session["System.RoleId"]==null?"":Convert.ToInt32(Sessio["System.RoleId"].ToString()))有错??望指出错误在哪里啊??
      

  7.   

    Session["System.RoleId"] 为NULL吧!
      

  8.   

    BindEmergGridData(Session["System.RoleId"]==null?"":Convert.ToInt32(Sessio["System.RoleId"].ToString()))报的错误是无法确定条件表达式的类型,string和int 之间没有隐式转换~~