title: How To Return Null From The Method Where We Return Data Table C# Web Application
body: <p>how to return the null or some null table from the method where i return data table in case of some error  my code is given below,</p>
  
  <pre><code>  public DataTable CostOfKilowat()
          {
              try
              {
                  DataTable CostDT = new DataTable();
                  int Dollar = Convert.ToInt32(txtCommission.Text);
                  CostDT = GetProducts();
                  DataTable Costtable = GetCostRate(CostDT, Dollar, "DATE,MTU,POWER,COST,VOLTAGE,PERUNITCOST", "DATE", "Group by ");
                  return Costtable;
              }
              catch 
              {
                  String script = "&lt;script&gt;alert('Enter Valid Cost')&lt;/script&gt;";
                  Page.RegisterStartupScript("script", script);
              }
              return ;
          }
  </code></pre>
  
  <p>hopes for your suggestions...</p>