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

  • Home
  • SEARCH
  • 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 537553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:56:21+00:00 2026-05-13T09:56:21+00:00

We have a project that needs to gather survey data. On one particular page

  • 0

We have a project that needs to gather survey data. On one particular page of the website, there are 21 questions each with a scale of 1-5 where the user selects one radio button for each question in the table.

The survey is being coded in VB.NET. The data submits to an SQL database. All the radio buttons are similarly named, so only the number changes for the question — thinking this would make it easier on the back end coding. In the code behind I was hoping to do something to the effect:

For i = 1 To 21
    If rbLWHFQ_Q(i)A1.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A1.Value)
    ElseIf rbLWHFQ_Q(i)_A2.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A2.Value)
    ElseIf rbLWHFQ_Q(i)_A3.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A3.Value)
    ElseIf rbLWHFQ_Q(i)_A4.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A4.Value)
    ElseIf rbLWHFQ_Q(i)_A5.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A5.Value)
    ElseIf rbLWHFQ_Q(i)_A6.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A6.Value)
    ElseIf rbLWHFQ_Q(i)_A7.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A7.Value)
    ElseIf rbLWHFQ_Q(i)_A8.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A8.Value)
    ElseIf rbLWHFQ_Q(i)_A9.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A9.Value)
    ElseIf rbLWHFQ_Q(i)_A10.Checked Then
        myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A10.Value)
    End If
Next i

My research tells me that it’s not possible to do what I am wanting without some special coding. I’ve seen mention of arrays in relation to these types of questions elsewhere, but I’m not familiar enough with arrays to see how they would work in this case.

Am I just going to have to create 21 sets of If…Else statements? 🙁

Here’s what the HTML looks like for a question, if that matters:

<tr class="statement220">
    <th><label for="rbLWHFQ_Q1_A1">1. Causing swelling in your ankles or legs?</label></th>
    <td title="0" >
        <input id="rbLWHFQ_Q1_A1" name="rbLWHFQ_Q1" type="radio" value="0" runat="server" />
    </td>
    <td title="1" >
        <input id="rbLWHFQ_Q1_A2" name="rbLWHFQ_Q1" type="radio" value="1" runat="server" />
    </td>
    <td title="2" >
        <input id="rbLWHFQ_Q1_A3" name="rbLWHFQ_Q1" type="radio" value="2" runat="server" />
    </td>
    <td title="3" >
        <input id="rbLWHFQ_Q1_A4" name="rbLWHFQ_Q1" type="radio" value="3" runat="server" />
    </td>
    <td title="4" >
        <input id="rbLWHFQ_Q1_A5" name="rbLWHFQ_Q1" type="radio" value="4" runat="server" />
    </td>
    <td title="5" >
        <input id="rbLWHFQ_Q1_A6" name="rbLWHFQ_Q1" type="radio" value="5" runat="server" />
    </td>
</tr>

As an aside, I know about RadioButtonLists, but in this case I’m needing to style the radio buttons in a special way and can’t get it to work when ASP renders the list items.

Updated to show I used it in my code
I’m not sure how StackOverflow works with regards to showing how something worked for you, but I just wanted to add this in case others come here looking for the answer. Basically, I used the code below:

Dim radioButtons()() As HtmlInputRadioButton = { _
    New HtmlInputRadioButton() {rbLWHFQ_Q1_A1, rbLWHFQ_Q1_A2, rbLWHFQ_Q1_A3, rbLWHFQ_Q1_A4, rbLWHFQ_Q1_A5, rbLWHFQ_Q1_A6}, _
    New HtmlInputRadioButton() {rbLWHFQ_Q2_A1, rbLWHFQ_Q2_A2, rbLWHFQ_Q2_A3, rbLWHFQ_Q2_A4, rbLWHFQ_Q2_A5, rbLWHFQ_Q2_A6}, _
    ...
    }

I created an array with the radio button group names:

Dim radioButtonGroupNames() As String = { _
    "@LWHFQ_Q1", _
    "@LWHFQ_Q2", _
    ...
    }

Then in my For…Loop I used:

For i = 0 To 20
    If radioButtons(i)(0).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(0).Value)
    ElseIf radioButtons(i)(1).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(1).Value)
    ElseIf radioButtons(i)(2).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(2).Value)
    ElseIf radioButtons(i)(3).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(3).Value)
    ElseIf radioButtons(i)(4).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(4).Value)
    ElseIf radioButtons(i)(5).Checked Then
        myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(5).Value)
    End If
Next i
  • 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-13T09:56:21+00:00Added an answer on May 13, 2026 at 9:56 am

    You need to make an array of arrays that hold your radiobuttons, like this:

    Dim radioButtons()() As HtmlInputRadioButton = { _
        New HtmlInputRadioButton { rbLWHFQ_Q1_A1, rbLWHFQ_Q1_A2, rbLWHFQ_Q1_A3, rbLWHFQ_Q1_A4, rbLWHFQ_Q1_A5 },
        New HtmlInputRadioButton { rbLWHFQ_Q2_A1, rbLWHFQ_Q2_A2, rbLWHFQ_Q2_A3, rbLWHFQ_Q2_A4, rbLWHFQ_Q2_A5 }, _
        ...
    }
    

    Note that the arrays are zero-based.

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

Sidebar

Related Questions

I have a project that needs to play video but not allow downloading. I'd
I have a home project that really needs to be in Source Control. I
I have a console application project in C# 2.0 that needs to write something
I have this large C++ project that I need to build on a platform
I have a project that I'm working on and I need to be able
I'm working on a project where I have 2 web services that need the
I have project that I'm working on that is going to require a webserver.
I have a project that I'm currently working on but it currently only supports
Suppose you have two seperate ASP.NET Web Application projects that both need to use
We have various php projects developed on windows (xampp) that need to be deployed

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.