title: How to check if an individual datatable row is empty or not?
body: <p>So in this dataset I want to check for the number of boys and number of girls and the total . The dataset returns <code>Table[1]</code> which has two rows, number of girls and number of boys .The <code>row[0][1]</code> returns the number of girls and the  <code>row[1][1]</code> returns the number of males 
  <img src="https://i.stack.imgur.com/pBuNn.png" alt="enter image description here"></p>
  
  <p>but whenever the <code>Table1</code> returns single row .ie count of either boys or girls , an <code>IndexOutOfRangeException</code> is thrown <code>There is no row at position 1</code> at the first <code>if</code> itself.</p>
  
  <p>Is my way of checking for empty datarow correct?</p>
  
  <p>And here is the code snippet</p>
  
  <pre><code> if (dsStudent != null &amp;&amp; dsStudent.Tables.Count &gt; 0 &amp;&amp; dsStudent.Tables[0].Rows.Count &gt; 0)
          {
              if (!(dsStudent.Tables[1].Rows[0]==null) &amp;&amp; !(dsStudent.Tables[1].Rows[1]==null)) //both are present
              {
                  lblbNumOfGirls.Text = dsStudent.Tables[1].Rows[0][1].ToString().Trim();
                  lblNumOfBoys.Text = dsStudent.Tables[1].Rows[1][1].ToString().Trim();
              }
              else if ((dsStudent.Tables[1].Rows[0][1].Equals(string.Empty))) //if girls are 0
              {
                  lblbNumOfGirls.Text="0";
                  lblNumOfBoys.Text = dsStudent.Tables[1].Rows[1][1].ToString().Trim();
              }
  
              else //if boys are 0
              {
                   lblNumOfBoys.Text="0";
                   lblbNumOfGirls.Text = dsStudent.Tables[1].Rows[0][1].ToString().Trim();
              }
  
              lblNumStudents.Text = (int.Parse(lblNumOfBoys.Text) + int.Parse(lblbNumOfGirls.Text)).ToString(); //total number of students
           }
  </code></pre>