title: how to pick up the gridview cell value to use in if statement within for loop
body: <p>I have a gridview as shown bellow. I want to loop through it and count all the instances where gender is set to male using a for loop but I don't know how to pick up the value in the Gender cell to check if it's equal to "M".</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CourseCode,ClientNumber" DataSourceID="SqlDataSource1" Height="237px" Width="801px"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="CourseCode" HeaderText="CourseCode" ReadOnly="True" SortExpression="CourseCode" /&gt;
              &lt;asp:BoundField DataField="ClientNumber" HeaderText="ClientNumber" ReadOnly="True" SortExpression="ClientNumber" /&gt;
              &lt;asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" /&gt;
              &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt;
              &lt;asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" /&gt;
              &lt;asp:BoundField DataField="Forename" HeaderText="Forename" SortExpression="Forename" /&gt;
              &lt;asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" /&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Thanks in advance for the help.</p>