2014-11-24 59 views
-3

即时编辑我的项目在编辑字段中出现错误错误“对象引用未设置”

未将对象引用设置为对象的实例。

我的代码是

如果(会话[ “ID”] == NULL) 的Response.Redirect( “Default.aspx的”);

else 
    { 
     if (!IsPostBack) 
     { 
      txtName.Text = Session["FullName"].ToString(); 
      txtAddress.Text = Session["Address"].ToString(); 
      txtPspori.Text = Session["Pspori"].ToString(); 
      txtTebini.Text = Session["Tebini"].ToString(); 
      txtTelAsi.Text = Session["Tel1"].ToString(); 
      txtTelKorek.Text = Session["Tel2"].ToString(); 
      txtTelother.Text = Session["Tel3"].ToString(); 
      } 
    } 

回答

4

使用`Session`你可能想研究使用`会议&& HttpContext.Current.Session`你会自己开车螺母之间的差异时,务必检查NULL的状态变化如ViewStates,Sessions

if(Session["Tel3"]!=null) 
txtTelother.Text = Session["Tel3"].ToString(); 
+0

也如果你的stat从random对象中随机返回空值,我知道这是从经验'Milad' – MethodMan 2014-11-24 18:20:46

+0

if(Session [“ID”] == null) Response.Redirect(“Default.aspx”); else if(!IsPostBack) tumbname.Text = Session [“FullName”]。 txtTelother.Text = Session [“Tel3”]。ToString(); } } – Milad 2014-11-24 18:35:02

+0

@DJKRAZE男人,你今天很忙!我见过你今天弹出几个问题,哈哈;-) – Kevin 2014-11-24 18:55:34

相关问题