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 7979971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:55:36+00:00 2026-06-04T09:55:36+00:00

I am using foreach loop insoide my view to display few radiobutton rows.. sample

  • 0

I am using foreach loop insoide my view to display few radiobutton rows..

sample radiobutton

<tr>
    <td width="30%">
    Integrity
    </td>
    <td width="17%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 1, new { id = "main_" + i + "__nested_integrity) Poor
    </td>
    <td width="18%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 2, new { id = "main_" + i + "__nested_integrity" }) Satisfactory
     </td>
     <td width="18%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 3, new { id = "main_" + i + "__nested_integrity" }) Outstanding
     </td>
     <td width="16%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 4, new { id = "main_" + i + "__nested_integrity" }) Off
     </td>
     </tr>

Because i was getting problem while Model binding therefore i created manual id to suit my requirement(different incremented id ).

But again problems comes with name attribute i think.
for first and every loop i am getting same name attribute(not incremented) i.e if i select radiobuttton from first loop then it deselect taht row from other loop.

Like

Loop1 id= "main_0__nested_integrity"
Loop2 id= "main_0__nested_integrity"
Loop1 name= "nested.integrity"
Loop2 name= "nested.integrity"

as you can see name attribute for all loops are same, with different id.
Now my Question is…Is it posssible to override name attribute of RadioButtonFor like id??

  • 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-06-04T09:55:37+00:00Added an answer on June 4, 2026 at 9:55 am

    Now my Question is…Is it posssible to override name attribute of RadioButtonFor like id??

    No, that’s not possible. The name attribute will be calculated from the lambda expression you passed as first argument.

    Personally I would use editor templates and not bother with any loops at all

    @model MainViewModel
    <table>
        <thead>
            ...
        </thead>
        <tbody>
            @Html.EditorFor(x => x.main)
        </tbody>
    </table>
    

    and in the corresponding editor template:

    @model ChildViewModel
    <tr>
        <td width="30%">
            Integrity
        </td>
        <td width="17%">
            @Html.RadioButtonFor(x => x.nested.integrity, 1) Poor
        </td>
        <td width="18%">
            @Html.RadioButtonFor(x => x.nested.integrity, 2) Satisfactory
         </td>
         <td width="18%">
             @Html.RadioButtonFor(x => x.nested.integrity, 3) Outstanding
         </td>
         <td width="16%">
             @Html.RadioButtonFor(x => x.nested.integrity, 4) Off
         </td>
    </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a foreach loop within PHP similar to this: foreach ($class->getAttributes() as
I'm using a foreach loop to get images from the graph API in facebook.
So if I am iterating using a foreach loop and I have a function
I'm using a foreach to loop through an IList of objects in a Partial
I know how to loop through items of an array using foreach and append
Im using MVC-Viewmodel, EF Model first on my project. I have a foreach loop
I am using a <% foreach ...%> loop to list a collection of items
Is there a way to iterate ValueCollection using straight for loop? (not foreach) e.g.
I was using a foreach loop to go through a list of data to
I have a package i am using the foreach loop to loop through the

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.