Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the selected value from RadioButtonList?

Tags:

c#

asp.net

People also ask

How to get Value RadioButtonList?

How to get selected value from ASP.NET RadioButtonList using JQuery. Below code will give you the Solution. var radioValue = $('#<%=RadioButtonList1. ClientID %> input[type=radio]:checked').

How to get RadioButtonList selected Value in c#?

string test = rb. SelectedValue; //May work fine SomeMethod(rb. SelectedValue);


The ASPX code will look something like this:

 <asp:RadioButtonList ID="rblist1" runat="server">

    <asp:ListItem Text ="Item1" Value="1" />
    <asp:ListItem Text ="Item2" Value="2" />
    <asp:ListItem Text ="Item3" Value="3" />
    <asp:ListItem Text ="Item4" Value="4" />

    </asp:RadioButtonList>

    <asp:Button ID="btn1" runat="server" OnClick="Button1_Click" Text="select value" />

And the code behind:

protected void Button1_Click(object sender, EventArgs e)
        {
            string selectedValue = rblist1.SelectedValue;
            Response.Write(selectedValue);
        }

Using your radio button's ID, try rb.SelectedValue.