Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4032218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:41:39+00:00 2026-05-20T11:41:39+00:00

I have 20 RadioButtonList s on a page. I need to create a validation

  • 0

I have 20 RadioButtonLists on a page.

I need to create a validation method to ensure that at least one of these RadioButtonLists has an item selected.

What kind of validation would I need to use for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:41:40+00:00Added an answer on May 20, 2026 at 11:41 am

    EDIT: Updated question based on comments and clarification.

    If you are validating against multiple RadioButtonLists then you need to use a CustomValidator and implement the server side check.

    Here is some test markup:

    <asp:RadioButtonList ID="rblstTest1" runat="server" ValidationGroup="Test">
        <asp:ListItem Text="Test 1" Value="1" />
        <asp:ListItem Text="Test 2" Value="2" />
        <asp:ListItem Text="Test 3" Value="3" />
    </asp:RadioButtonList>
    <br /><br />
    <asp:RadioButtonList ID="rblstTest2" runat="server" ValidationGroup="Test">
        <asp:ListItem Text="Test 1" Value="1" />
        <asp:ListItem Text="Test 2" Value="2" />
        <asp:ListItem Text="Test 3" Value="3" />
    </asp:RadioButtonList><br />
    <asp:Button ID="btnTestRb" runat="server" ValidationGroup="Test" Text="Test RBL" 
        OnClick="btnTestRb_Click" />
    <asp:CustomValidator runat="server" ValidationGroup="Test" ID="cvTest" 
        ControlToValidate="rblstTest1" OnServerValidate="cvTest_ServerValidate" 
        ValidateEmptyText="true" Enabled="true" display="Dynamic" SetFocusOnError="true"
        ErrorMessage="You must select at least one item." /> 
    

    Use the following extension method to find all the RadioButtonList controls (Source):

    static class ControlExtension
    {
        public static IEnumerable<Control> GetAllControls(this Control parent)
        {
            foreach (Control control in parent.Controls)
            {
                yield return control;
                foreach (Control descendant in control.GetAllControls())
                {
                    yield return descendant;
                }
            }
        }
    } 
    

    Then implement the server side CustomValidator check:

    protected void cvTest_ServerValidate(object sender, ServerValidateEventArgs e)
    {            
        int count = this.GetAllControls().OfType<RadioButtonList>().
            Where(lst => lst.SelectedItem != null).Count();
        e.IsValid = (count > 0);
     }
    

    I have tested the above example and it seems to do exactly what you need. You should be able to switch it to VB pretty easily. Hope this solves your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i need to modify my code a little bit. i have a page
I have a page with a radiobuttonlist and textarea. data is displayed dynamically within
We have a need to customize the logic of our N2 authentication to add
i have a page built in asp.net c#. it holds a list of radio
I have a situation where I have a page in ASP.NET. In this page
having an issue supporting IE6 (meh).. I have an update panel that is triggered
I'm working on an ASP.NET where I have a RadListView (Telerik). Inside every RadListView's
I'm trying to on Page_Load hide all my RadioButtonLists but I can't seem to
I posted a similar RBL question but I have a new issue arising so
OK, Im really stumped and hoping this is something simple. I have a form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.