title: System.NullReferenceException: Object reference not set to an instance of an object
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6212629/system-nullreferenceexception-object-reference-not-set-to-an-instance-of-an-obje">System.NullReferenceException: Object reference not set to an instance of an object</a>  </p>
  </blockquote>
  
  
  
  <p>look at my code </p>
  
  <pre><code>if (ViewState["Edit"].ToString() == "new") { 
  }
  else {
        row = _section.GetBannerEntry(ViewState["Edit"].ToString()); 
  }
  </code></pre>
  
  <p>I was getting the error on this line <code>if (ViewState["Edit"].ToString() == "new")</code> I replaced with <code>if (ViewState["Edit"] != null &amp;&amp; ViewState["Edit"].ToString() == "new")</code> it works.</p>
  
  <p>Now I am getting the same error here in <code>else row = _section.GetBannerEntry(ViewState["Edit"].ToString());</code></p>
  
  <p>please help</p>