title: How can I solve "Object reference not set to an instance of an object"?
body: <p>This is page load where I make two columns in data table and also connect database with dropdown-list:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!this.IsPostBack)  
      {    
          DataTable dt = new DataTable();  
          dt.Columns.AddRange(new DataColumn[2] { new   DataColumn("product_name"), new DataColumn("Quantity") });  
          ViewState["sales"] = dt;  
          GridView1.DataBind();  
  
          txt_productname.DataSource = sic.get_product_name_for_textbox();  
          txt_productname.DataTextField = "product_name";  
          txt_productname.DataValueField = "product_id";  
          txt_productname.DataBind();  
  
          txt_customername.DataSource =   sic.get_customer_name_for_textbox();  
          txt_customername.DataTextField = "customer_name";  
          txt_customername.DataValueField = "customer_id";  
          txt_customername.DataBind();  
      }  
  </code></pre>
  
  <p>Code side this is a temporary data grid:</p>
  
  <pre><code>protected void btn_insert_Click(object sender, EventArgs e)
      if (string.IsNullOrWhiteSpace(txt_productname.Text) ||string.IsNullOrWhiteSpace(txt_quantity.Text))
      {
          Response.Write("&lt;script LANGUAGE='JavaScript'&gt;alert('NotAllowNull')     &lt;/script&gt;");  
      }
      else
      {
          DataTable dt = null;
          if (Session["DataTable"] != null)
              dt = (DataTable)Session["DataTable"];
          else
          {
          }
  
          dt.Rows.Add(txt_productname.SelectedValue.ToString());
          dt.Rows.Add(txt_quantity.Text);
  
          GridView1.DataSource = dt;
          GridView1.DataBind();
          Session["DataTable"] = dt;
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>An exception of type 'System.NullReferenceException' occurred in
    Security Managment System.dll but was not handled in user code</p>
    
    <p>Additional information: Object reference not set to an instance of an
    object.</p>
  </blockquote>