0

I have a RadioButtonList inside the GridView However, in code behind, I cannot access the RadioButtonList, but I can access GridView control.
This is the html markup

<body>
<form id="form1" runat="server">
    <asp:GridView ID="gvQuestion" runat="server" AutoGenerateColumns="false" DataKeyNames="Id" OnRowDataBound="gvQuestion_RowDataBound">
        <Columns>
            <asp:TemplateField runat="server">
                <ItemTemplate>
                    <asp:Label ID="lblQuestion" runat="server" Text='<%# Eval("Question")%>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:RadioButtonList ID="rblOptions" runat="server"></asp:RadioButtonList>
                </EditItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</form>


KlynkC
  • 949
  • 1
  • 6
  • 11
  • 1
    _"in code behind, I cannot access the RadioButtonList"_ so you want us to fix the code that you don't show? – Tim Schmelter Jun 12 '15 at 07:19
  • the code behind simple is `protected void load(){ rblOptions. }` but Visual Studio can not found the item named `rblOptions` – KlynkC Jun 12 '15 at 07:22
  • It's in an `EditItemTemplate`, you need to do that in `RoewDataBound` event with apropriate `RowType.DataRow` and `DataControlRowState.Edit`. Or you have to loop the rows. Here's an example: http://stackoverflow.com/questions/14584175/how-to-find-control-in-edit-item-template – Tim Schmelter Jun 12 '15 at 07:30

0 Answers0