title: Convert string to date from an excel file asp.net mvc
body: <p>After putting this code and importing excel file, I'm always encountering data tables with no values even though most of the rows has values in the excel file. My problem is to convert string (ex. 20131022) to date (yyyyMMdd) after importing excel file and show "N/A" as the value if it is null or 0.</p>
  
  <p>Here's my code:</p>
  
  <p>//AdminController.cs</p>
  
  <pre><code>if (data.ordDate == "0" || data.ordDate == null)
  {
  Response.Write("N/A");
  }
  else
  {
  data.ordDate = ds.Tables[0].Rows[i]["ordDate"].ToString();
  }
  
  if (data.paymentDate == "0" || data.paymentDate == null)
  {
  Response.Write("N/A");
  }
  else
  {
  data.paymentDate = ds.Tables[0].Rows[i]["paymentDate"].ToString();
  }
  </code></pre>
  
  <p>//ExcelData.cs</p>
  
  <pre><code>public class ExcelData
      {
          public string ordDate { get; set; } 
          public string paymentDate { get; set; }
      }
  </code></pre>
  
  <p>//_ExcelData.cshtml</p>
  
  <pre><code>@model IEnumerable&lt;ExcelData&gt;
  
  &lt;table class="table table-striped table-bordered bootstrap-datatable"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Order Date&lt;/th&gt;
              &lt;th&gt;Payment Date&lt;/th&gt;
  
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @try
          {
              foreach (var data in Model)
              {
              &lt;tr&gt;
                  &lt;td&gt;@data.ordDate&lt;/td&gt;
                  &lt;td&gt;@data.paymentDate&lt;/td&gt;           
              &lt;/tr&gt;
              }
          }
          catch
          {
              &lt;tr&gt;
                  &lt;td colspan="5"&gt;No data available.&lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Can you help me guys with this?
  My whole day is so f*<em>*</em>* up with this code. I'm new in ASP.NET MVC. I tried the other format but still it shows nothing except for the row of 
  N/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/A
  on the top of the data table.</p>
  
  <p>Thanks in advance to those who are willing to help! :)</p>