Get the selected radio button in a datalist RRS feed

  • Question

  • User-526635386 posted


    Could someone please point me in the right direction? I have a datalist that is generating a list of (grouped) radio buttons that have a dynamic name and value. I have searched all over the web but can't find a way to get the name and value of the selected radio button. My aspx looks like this:

    <asp:Repeater id="OptionList" runat="server">
    <div class="Heading_2"><b>Optionals:</b></div>
    <div class="Text_2"><b><%# DisplayHeaderIfNeeded(Container.DataItem("GroupName")) %></b></div>
    <div class="Text_2"><input type="radio" name=<%#Container.DataItem("OptProdType")%> value=<%#Container.DataItem("OptPID")%>><%#Container.DataItem("PName")%> Add <%#Container.DataItem("SellingPrice")%></div>
    <% If OptionList.Items.Count = 0 Then%>
    <div class="Heading_2">No options are available for this product.</p></div>
    <% end if %>

    The end result looks like this:


    So 'Bag' is one group and 'Monitor' is another group in this example. There are many groups and depending on the product chosen the datalist/radio buttons would be populated accordingly. I would like to get the name and value of the selected items in the codebehind but I am not sure how. Every example I have looked at you need to know the name value of the radio button but because it is generated dynamically I do not know this. I am using VB.Net.


    Tuesday, January 15, 2019 1:37 PM

All replies

  • User475983607 posted

    You are using HTML and not standard server controls so you need to know the name of the inputs in order to get the value from the request body.


    Tuesday, January 15, 2019 1:45 PM