title: VB.NET checkbox problems
body: <p>Web site in Visual Studio 2010 with VB. I created a GridView with a checkbox column, but my code behind is not recognizing the checked rows. Runs through with no error but never sees a checked row.</p>
  
  <pre><code> &lt;asp:GridView 
      ID="gvwOrderDetails" 
      DataKeyNames="ID"
      runat="server" 
      BackColor="White" 
      BorderColor="#DEDFDE" 
      BorderStyle="None" 
      BorderWidth="1px" 
      CellPadding="4" 
      ForeColor="Black" 
      GridLines="Vertical"&gt;
      &lt;AlternatingRowStyle BackColor="White" /&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox ID="OrderSelector" runat="server" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
      &lt;FooterStyle BackColor="#CCCC99" /&gt;
      &lt;HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /&gt;
      &lt;RowStyle BackColor="#F7F7DE" /&gt;
      &lt;SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /&gt;
      &lt;SortedAscendingCellStyle BackColor="#FBFBF2" /&gt;
      &lt;SortedAscendingHeaderStyle BackColor="#848384" /&gt;
      &lt;SortedDescendingCellStyle BackColor="#EAEAD3" /&gt;
      &lt;SortedDescendingHeaderStyle BackColor="#575357" /&gt;
  &lt;/asp:GridView&gt;
  
  
  Protected Sub btnVoid_Click(sender As Object, e As System.EventArgs) Handles btnVoid.Click
  
          Dim atLeastOneRowVoided As Boolean = False
          For Each row As GridViewRow In gvwOrderDetails.Rows
  
              Dim cb As CheckBox = TryCast(row.Cells(0).FindControl("OrderSelector"), CheckBox)
  
                  If cb IsNot Nothing AndAlso cb.Checked Then
                       atLeastOneRowVoided = True
                       Dim orderID As Integer = _
                      Convert.ToInt32(gvwOrderDetails.DataKeys(row.RowIndex).Value)
                  lbl1.Text &amp;= String.Format( _
                      "This would have voided ProductID {0}&lt;br /&gt;", orderID)
  
              End If
          Next
  
      End Sub
  </code></pre>