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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:34:12+00:00 2026-05-15T02:34:12+00:00

I try to post data row in which radio button is checked but failed,

  • 0

I try to post data row in which radio button is checked but failed, what is wrong?

View:

<form id="numbers-form" method="post" action="/Numbers/Numbers">
<table id="numbers">
    <tr>
        <th>
            prvi_br
        </th>
        <th>
            drugi_br
        </th>
        <th>
            treci_br
        </th>
    </tr>
<% int rb = 1; %>
<% foreach (var item in Model) { %>
    <tr>
        <td>
        <%= Html.Encode(item.prvi_br) %>
        <input type="radio" name="<%= Html.Encode(rb) %>"  value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.prvi_br) %>'/>
        </td>
        <td>
        <%= Html.Encode(item.drugi_br) %>
        <input type="radio" name="<%= Html.Encode(rb)%>" value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.drugi_br) %>'/>
        </td>
        <td>
        <%= Html.Encode(item.treci_br) %>
        <input type="radio" name="<%= Html.Encode(rb)%>" value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.treci_br) %>'/>
        </td>
    </tr>
<% rb++; %>

<% } %>
</table>
        <p>
            <input type="submit" value="Save" />
        </p>
</form>

Controller action:

    [HttpPost]
    public ActionResult Numbers(int[] rb)
    {
        brojevi br = new brojevi();
        for (int i = 1; i <= rb.Length; i++) //in this line I have error:Object reference not set to an instance of an object.
        {
            br.prvi_br = i;
            br.drugi_br = i+1;
            br.treci_br = i+3;
        }
        numbers.AddTobrojevi(br);
        numbers.SaveChanges();
        return View();
    }
  • 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-15T02:34:12+00:00Added an answer on May 15, 2026 at 2:34 am

    Shouldn’t your Numbers method accept a FormCollection instead of an int[]?

    Something like this seems to work, but not knowing your functionality, it’s hard to tell if it will suit your purpose:

    [HttpPost]
    public ActionResult Numbers(FormCollection fc)
    {
    
        foreach (string key in fc.Keys)
        {
            int i = Convert.ToInt32(key);
            // i = the number of the item that was selected.
        }
    
        return View();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i try to post data by ajax , it gives me name value bu
I try to make a registration form. When user post the fields, i check
I have a form which contains list of data, I added a checkbox in
When I try to post data from http to https, urllib2 does not return
<form class=formp action= method=post enctype=multipart/form-data id=frm name=wjd> <input type=hidden name=MAX_FILE_SIZE value=2000000/> <p>Gerecht:</p><p>Prijs:</p><p>Plaatje:</p><p>Upload:</p> <?php $resultmenus
On my form, I have an echo which links to the data in my
HttpRequestValidationException occurs when I try post when txtBulletin contains any HTML, like Hello<br />World
Every time I try to post to twitter in my rails app, the first
I could try to post and explain the exact query I'm trying to run,
I am using the PHP SDK to try and post a simple action using

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.