Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal">
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <ItemTemplate>
            <table class="auto-style1">
                <tr>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Q1."></asp:Label>
                    </td>
                    <td colspan="4">
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Q1") %>'></asp:Label>
                    </td>
                </tr>
                <tr>

                    <td colspan="4">
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                        </asp:RadioButtonList>
                    </td>
                </tr>

                <tr>
                    <td>
                        <asp:Label ID="Label3" runat="server" Text="Q2."></asp:Label>
                    </td>
                    <td colspan="4">
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("Q2") %>'></asp:Label>
                    </td>
                </tr>
                <tr>

                     <td>
                         <asp:RadioButtonList ID="RadioButtonList2" runat="server">
                         </asp:RadioButtonList>
                     </td>

                </tr>
                 <tr>
                    <td>
                        <asp:Label ID="Label5" runat="server" Text="Q3."></asp:Label>
                    </td>
                    <td colspan="4">
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("Q3") %>'></asp:Label>
                    </td>
                </tr>
                <tr>

                     <td>
                         <asp:RadioButtonList ID="RadioButtonList3" runat="server">
                         </asp:RadioButtonList>
                     </td>

                </tr>
                 <tr>
                    <td>
                        <asp:Label ID="Label7" runat="server" Text="Q4."></asp:Label>
                    </td>
                    <td colspan="4">
                        <asp:Label ID="Label8" runat="server" Text='<%# Bind("Q4") %>'></asp:Label>
                    </td>
                </tr>
                <tr>

                     <td>
                         <asp:RadioButtonList ID="RadioButtonList4" runat="server">
                         </asp:RadioButtonList>
                     </td>


                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="4">
                        <asp:Button ID="Button2" runat="server" Text="Submit" />
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        <SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />

    </asp:DataList>
Posted
Comments
What have you tried?

1 solution

You can access the radio button using DataListItem.FindControl()[^]
You can do something like-
C#
RadioButtonList rbtnlist=( RadioButtonList)DataList1.Items[0].FindControl("RadioButtonList1"));

This will get you the radiobuttonlist from the first item of the datalist. You may iterate through all the rows using for or foreach loop to find all the values.

Hope, it helps :)
 
Share this answer
 
Comments
Member 10774811 13-Jul-15 9:20am    
Thank you ..:)
Suvendu Shekhar Giri 13-Jul-15 9:33am    
Glad to know that it helped :)

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