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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:06:59+00:00 2026-05-24T21:06:59+00:00

Is there a best (or preferred) way to pass information from an HTML table

  • 0

Is there a “best” (or preferred) way to pass information from an HTML table in an ASP.Net MVC view to a controller? I am working with MVC2, and if I stick with using the Context objects (mainly Request.Form[::variables::], I’m at a loss as to how to retrieve information presented in the view using the table/table cell structure. The table I am working with has a check box corresponding to each row of data, and I want to make the data from “checked” rows available to the controller. The following quick fixes come to mind:

1) Since the table in question has a check box, and HTML elements of type “input” have the “id” attribute, the data values could be stored in some kind of concatenated string in the “id” attribute for the check box.

2) Similar to the above misuse of the check box “id” attribute, the data values could be stored in the “text” attribute for a text (textbox) input element.

…but that all seems really klugey, even if it does work. I am relatively new to the field of web programming/development (although not new to programming), so if anyone can suggest alternate methods and/or technologies (I’m open to trying stuff via JavaScript, etc) I would appreciate it. I would appreciate even just links to relevant tutorials (or, related StackOverflow posts I may have missed). :-p

  • 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-24T21:06:59+00:00Added an answer on May 24, 2026 at 9:06 pm

    If you have a form like this:

    <form action="." method="POST">
      <table>
        <tbody>
          <tr>
            <td>
              <input type="checkbox" name="checkedValues" value="1" />
            </td>
          </tr>
          <tr>
            <td>
              <input type="checkbox" name="checkedValues" value="2" />
            </td>
          </tr>
          <tr>
            <td>
              <input type="checkbox" name="checkedValues" value="3" />
            </td>
          </tr>
        </tbody>
      </table>
    </form>
    

    That will map to this parameter in your controller action when a post occurs, where the values of the checked boxes are stored in the checkedValues array:

    public ActionResult MyAction(int[] checkedValues)
    {
    }
    

    The values of the check boxes can be strings as well, if that’s preferred.

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

Sidebar

Related Questions

Is there an accepted/expected best-practice way to encapsulate the model portion of ASP.NET MVC
In ASP.NET MVC how can I pass a String variable to the _Layout.cshtml view;
In ASP.NET WebForms I want to pass arbitrary data from server to client and
Is there a best-practice or common way in JavaScript to have class members as
Is there a best way to turn an integer into its month name in
Is there a best (see below) way to append two byte arrays in C#?
is there a best way to deploy to the GAC? is dragging the dll
Just curious if there is an established best way to target child elements inside
I have built an ASP.NET MVC app some time ago, and after a few
I am wondering what would be the best/preferred way to write a scanning app

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.