Click here to Skip to main content
15,996,848 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
i am developing online test system using as.net. i have used repeater control and within repeater label for question and radiobuttons for option i.e mcq opion , i am not able to access those radiobutton to create final report(result),also i have bound those radiobutton with database using eval method ,and my datbase contaion column as col1:question,col2: optiona col3:optionb, col4:optionc col5:optiond col5:correctoption so i want to compare the value of selected radio button with column correctoption to generate report my aspx code:
Hide   Expand    Copy Code
<asp:Repeater ID="Repeater1" runat="server">
   <HeaderTemplate>

   </HeaderTemplate>
   <ItemTemplate>
   <div align="left">
   <table >
   <tr >
   <td>
       <asp:Label ID="Label1" runat="server" Text='<%# Eval("Question") %>' CssClass="label-primary" Font-Size="Small"></asp:Label>
    <br /></td>
    </tr>
    <tr>
    <td class="pull-left">
        <asp:RadioButton ID="RadioButton1" runat="server" OnCheckedChanged="check"  Text='<%# Eval("optiona") %>'  GroupName="group"/>
       <br /></td></tr>
       <tr>
       <td class="pull-left">
       <asp:RadioButton ID="RadioButton2" runat="server" OnCheckedChanged="check" Text='<%# Eval("optionb") %>'  GroupName="group"/>
       <br />
       </td>
             </tr>
       <tr>
       <td class="pull-left">
       <asp:RadioButton ID="RadioButton3" runat="server" OnCheckedChanged="check" Text='<%# Eval("optionc") %>'  GroupName="group"/>
       <br /></td></tr>
       <tr>
       <td class="pull-left">
       <asp:RadioButton ID="RadioButton4" runat="server"  OnCheckedChanged="check" Text='<%# Eval("optiond") %>'  GroupName="group"/>
   </td>
   </tr>
   </table>
   </div>
   </ItemTemplate>
   <SeparatorTemplate>
   <br /><hr /><br />
   </SeparatorTemplate>
   <FooterTemplate>
   <table>
   <tr><td>
       <asp:LinkButton ID="SubmitAnswers" runat="server" CssClass="alert-link" Font-Bold="true" Font-Size="X-Large" OnClick="lnk_click">submit</asp:LinkButton></td><td width="15px"></td><td>
           <asp:LinkButton ID="LinkButton2" runat="server" CssClass="alert-link" Font-Bold="true" Font-Size="X-Large">Cancel</asp:LinkButton></td></tr>
   </table>
   </FooterTemplate>
   </asp:Repeater>
creating report means i have show the result the counting of the marks that end user scored.so for that i have to compare the value which end user has selected i.e radiobutton he/she has selected with the correct ans which i have stored in database with table name test my database table test questionID int question nvarchar(255) optiona  varchar(255)    optionb varchar(255)    optionc varchar(255)    optiond varchar(255)    correctans varchar(255) questioncat varchar(255)    thank you for your concern and reply. :)
Posted
Updated 2-Oct-15 5:39am
v2

1 solution

I think you are looking for - How get selected radiobutton id in repeater?[^].
C#
string rdValues="";
foreach (RepeaterItem ri in RepDetails.Items)
{
    RadioButton rd = (RadioButton)ri.FindControl("rdioId1");

    if (rd.Checked == true)
    {
        rdValues=rdValues+rd.Text;
    }
}
 
Share this answer
 
Comments
Rohan Chavan 2-Oct-15 12:38pm    
perfect thank you so much sir!!1
Most welcome Rohan. Please accept the 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