Click here to Skip to main content
15,918,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to store value assigned with radio buttons after submitting the form by using post method but i don't know the code exactly and i'm tried to do is

<form id="form1" runat="server" method="post" action="Dummy3.aspx">
        <div>
            <asp:Repeater ID="QuestionRepeater" runat="server">
                <HeaderTemplate>
                    <table>
                </HeaderTemplate>
                <SeparatorTemplate>
                    <tr>
                        <td>
                            <br />
                        </td>
                    </tr>
                </SeparatorTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                           <%#Eval("Question1") %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButton runat="server" ID="rb1" GroupName="Rb_Choice" OnCheckedChanged="CheckChanged"></asp:RadioButton><%#Eval("Choice_1") %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButton runat="server" ID="rb2" GroupName="Rb_Choice" OnCheckedChanged="CheckChanged"></asp:RadioButton><%#Eval("Choice_2") %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButton runat="server" ID="rb3" GroupName="Rb_Choice" OnCheckedChanged="CheckChanged"></asp:RadioButton><%#Eval("Choice_3") %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButton runat="server" ID="rb4" GroupName="Rb_Choice" OnCheckedChanged="CheckChanged"></asp:RadioButton><%#Eval("Choice_4") %>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <br />
            <asp:Button ID="Submit" Text="Submit" runat="server" />
        </div>
    </form>

is my front end page then any one suggest me how to write the code for get values of radio buttons after submit

What I have tried:

in my back end page 

QuestionRepeater = Request.Form["QuestionRepeater"];
            foreach (RepeaterItem item in QuestionRepeater.item)
            {
                RadioButton rb = (RadioButton)item.FindControl("Rb_Choice");
                if (rb != sender)
                {
                    rb.Checked = false;
                }
            }


it does not take questionrepeater.item
it shows error in questionrepeater.item
can any one help me this out...please
Posted
Updated 14-Feb-18 7:03am
v2

1 solution

foreach (RepeaterItem item in rptItems.Items)
{
    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    {
        var checkBox = (CheckBox)item.FindControl("ckbActive");

        //Do something with your checkbox...
        checkBox.Checked = true;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900