Question: i have:

```
<asp:TemplateField HeaderText="Choose Option">
<ItemTemplate>
 <asp:RadioButtonList ID="rdbChoice" runat="server" RepeatDirection="Horizontal">
 <asp:ListItem Value="A">A</asp:ListItem>
 <asp:ListItem Value="B">B</asp:ListItem>
 <asp:ListItem Value="C">C</asp:ListItem>
 </asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>

```

In the button click, I want to get the `RadioButtonList.SelectedValue`. I try:

```
protected void btnsubmit_Click(object sender, EventArgs e)
 {
   for (int i = 0; i <= gvQuestion.Rows.Count - 1; i++)
        {
            RadioButtonList rd1 = (RadioButtonList)gvQuestion.FindControl("rdbChoice");
            string rd = rd1.SelectedValue.ToString();
        }
 }

```

But i get an error `Object reference not set to an instance of an object.` What is my mistake?

Answer: 
The [NamingContainer](http://msdn.microsoft.com/en-us/library/system.web.ui.control.namingcontainer.aspx) of your RadioButtonList is the GridViewRow not the GridView, so this works:

```
for (int i = 0; i <= gvQuestion.Rows.Count - 1; i++)
{
   RadioButtonList rdbChoice = (RadioButtonList)gvQuestion.Rows[i].FindControl("rdbChoice");
   string rd = rdbChoice.SelectedValue;
}

```

Keep in mind that [FindControl](http://msdn.microsoft.com/en-us/library/system.web.ui.control.findcontrol.aspx) does not look recursively into child container, it only searches the current NamingContainer for the given ID.
Good afternoon, I believe that the issue is that you are not filtering out the header and footer rows in your for loop. Inside of your for loop make sure that you check that the RowType Property of the Row that you are on is equal to DataControlRowType.DataRow:

```
 for (int i = 0; i <= gvQuestion.Rows.Count - 1; i++)
 {
      if (gvQuestion.Rows[i].RowType == DataControlRowType.DataRow)
      {
           RadioButtonList rd1 = (RadioButtonList)gvQuestion.Rows[0].FindControl("rdbChoice");
           string rd = rd1.SelectedValue.ToString();
      }
 }

```