Aim: `Gridview` with checkbox on each line, user then clicks a button and all ticked lines are actioned in the button code. I need the ID's of all the records where the `CheckBox` is checked.

Error: 

> 
> Object reference not set to an instance of an object.
> 
> 
> 

on row: `ID_Current = row.FindControl("ID").ToString` 

if I change the to `ID_Current = DirectCast(row.FindControl("cbSelect"), CheckBox).Checked` I get 'True' as a result but I already know that and want to get the ID. 

Aspx-Code with my `Gridview`:

```
<asp:Panel ID="ActionGrid" runat="Server">
    <h2>Actions To Edit</h2>
    <asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True" AlternatingRowStyle-CssClass="alt" AutoGenerateColumns="False" CssClass="mGrid" DataKeyNames="UPRN" DataSourceID="SqlDataSource3" EmptyDataText="There are no data records to display." Font-Size="Medium" PagerStyle-CssClass="pgr" Width="1000px">
        <%--  AutoGenerateEditButton="True"--%>
        <Columns>
            <asp:TemplateField HeaderText="Select">
                <ItemTemplate>
                    <asp:CheckBox ID="cbSelect" runat="server" AutoPostBack="false" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField ControlStyle-Width="50px" DataField="UPRN" HeaderText="UPRN" ReadOnly="True" SortExpression="UPRN" />
            <asp:BoundField DataField="LocationItemPosition" HeaderText="Location Item Position" ReadOnly="True" SortExpression="LocationItemPosition" />
            <asp:TemplateField HeaderText="Surveye" SortExpression="SurveyDate">
                <ItemTemplate>
                    <asp:Label ID="lblSurveyDate" runat="server" Text='<%# apFunctionCharacters.fncDateTidy(Eval("SurveyDate"))%>' />
                </ItemTemplate>
            </asp:TemplateField>

            <asp:BoundField DataField="ItemRef" HeaderText="Item Ref" ReadOnly="True" SortExpression="ItemRef" />
            <asp:BoundField DataField="OverallRiskCategory" HeaderText="Overall Risk Category" ReadOnly="True" SortExpression="OverallRiskCategory" />
            <asp:BoundField DataField="Comments" HeaderText="Comments" ReadOnly="True" SortExpression="Comments" />

        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    <asp:Button ID="btnChangeToNA" runat="server" CssClass="Button" Text="Change to NA" />
    <asp:Label ID="lblTest" runat="server" Text="Label"></asp:Label>
</asp:Panel>

```

Submit button:

```
<asp:Button ID="btnChangeToNA" runat="server" CssClass="Button" Text="Change to NA" />

```

.aspx.vb stored procedure/action code

```
Protected Sub btnChangeToNA_Click(sender As Object, e As EventArgs) Handles btnChangeToNA.Click
    For Each row As GridViewRow In GridView3.Rows

        Dim ID_Current As String = ""
        'read the label            
        If DirectCast(row.FindControl("cbSelect"), CheckBox).Checked Then
            ID_Current = row.FindControl("ID").ToString

            ' change value
            '############stored procedure here

            Dim connection As SqlConnection
            Dim command As New SqlCommand
            Dim ds As New DataSet
            Dim ConnectionString1 As String = System.Configuration.ConfigurationManager.ConnectionStrings("MY_SQL").ToString()
            connection = New SqlConnection(ConnectionString1)

            connection.Open()

            With command
                .Connection = connection
                .CommandText = "spChangeValue "
                .CommandType = CommandType.StoredProcedure
                .Parameters.Clear()
                .Parameters.AddWithValue("@ID_Current", ID_Current)
                .ExecuteNonQuery()
            End With
            '#############################
            lblTest.Text += ID_Current
        End If
        'Loop 
    Next     
End Sub

```