title: Dataset in an If condition
body: <p>I am still in the process of learning Asp.Net. I have a question . I was using an if condition in which i was checking dataset values. It is throwing me an exception whenever it is checking the condition as the dataset has not got any value. How to overcome this. 
   Code for this is here:</p>
  
  <p>DataSet ds = merchant.getIsactiveIsconfirmedforcancelaccount(merchantID);</p>
  
  <pre><code>if (_merchant.PackageID == (int)CommonHelper.Package.Free &amp;&amp; _merchant.AccountStatus.Contains("Awaiting"))
          {
              spnMerchantActiveStatus.InnerHtml = ApplicationData.MSG_AWAITING_CONFIRMATION;
          }
          ***else if ((ds.Tables[0].Rows[0]["IsConfirmed"]).ToString() == "True" &amp;&amp; (ds.Tables[0].Rows[0]["Active"]).ToString() == "N")***
          {
               _merchant.AccountStatus = "Cancelled";
               spnMerchantActiveStatus.InnerHtml = _merchant.AccountStatus;
  
          }
  
          else if(_merchant.PackageID != (int)CommonHelper.Package.Free &amp;&amp; ds1.Tables[0].Rows.Count == 0 &amp;&amp; (ds2.Tables[0].Rows[0]["ConfirmationSrc"]).ToString() == "Admin")
          {
               _merchant.AccountStatus = "Free Trial";
               spnMerchantActiveStatus.InnerHtml = _merchant.AccountStatus;
          }
          else
              spnMerchantActiveStatus.InnerHtml = _merchant.AccountStatus;
      }
  </code></pre>
  
  <p>The exception here is "There is no row at position 0."</p>