title: how to get data from dataset
body: <p>my Gridview always get null datatable ,error message:<code>Object reference not set to an instance of an object.</code>, but i donot know which code is missing. <br />
  Thanks for help!!! <br/></p>
  
  <p><strong>.CS</strong><br/></p>
  
  <pre><code>protected void btn_Click(object sender, EventArgs e)
  {
          DataSet ds = new DataSet();
          DataTable dt = new DataTable("abc");
          dt = getDT(formatDate); //string[] formatDate ={2013-01-01,2013-05-01..}
          ds.Tables.Add(dt);
          GridView2.DataSource = ds.Tables["abc"].DefaultView; 
           //if change to dt , it works ==&gt; GridView2.DataSource =dt;
          GridView2.DataBind();
      }
  
  }
  
  private DataTable getDT(string[] date)
  {
      DataTable dt = new DataTable();
  
      dt.Columns.Add("RowID", typeof(Int16));
      dt.Columns.Add("Date", typeof(DateTime));
  
      for (int i = 0; i &lt; date.Length; i++)
      {
          dt.Rows.Add(i + 1, date[i]);
      }
      return dt;
  }
  </code></pre>