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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:11:24+00:00 2026-06-08T23:11:24+00:00

If I have a CheckBoxList within a form, like this… @using (Html.BeginForm("Save", "Product", FormMethod.Post))

  • 0

If I have a CheckBoxList within a form, like this…

@using (Html.BeginForm("Save", "Product", FormMethod.Post))
{
    ...

    @Html.CheckBoxList("Categories", Model.AllCategories);

    ...
}

… how can I get a list of selected values (checked values) in my controller action?

For example, if the check box list has items with values of:

Cat. 1

Cat. 2

Cat. 3

Cat. 4

…and Cat. 2 and Cat. 3 are selected, how can I get an array containing those values?

  • 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-08T23:11:26+00:00Added an answer on June 8, 2026 at 11:11 pm

    In the simplest case, the controller action should look like this (in the Product controller):

    [HttpPost]
    public ActionResult Save(string[] Categories)
    {
        // Process selected checkbox values here, using the Categories array
        ...
    }
    

    In a more complex case (with more form fields), it may be better to use a view model, and add a Categories property to it.

    public class MyViewModel
    {
        ...
    
        public string[] Categories { get; set; }
    
        ...
    }
    

    Controller action:

    [HttpPost]
    public ActionResult Save(MyViewModel model)
    {
        // Process selected checkbox values here, using the model.Categories array
        ...
    }
    

    Simple Q & A, but hopefully it will help someone looking for the answer (like I was, when I first started learning ASP.NET MVC).

    P.S. If you’ve got something better or more detailed, please post it.

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

Sidebar

Related Questions

I have some checkboxlist like this: <asp:CheckBoxList ID=G1 runat=server> <asp:ListItem Value=Comunicações Unificadas Text=Comunicações Unificadas
I'm having trouble figuring this out. If I have a checkboxlist inside a usercontrol,
I have a web form with some TextBoxes and CheckBoxList . I want to
I have an asp.net panel that contains a checkboxlist. I'd like to resize it
Hey there, i got this very annoying problem: I have a CheckBoxList getting items
I have an <asp:CheckBoxList> using RepeatLayout=Flow in my page I dynamically assign values to.
I have a aspx page which contains the following CheckBoxList. <form id=form1 runat=server> <asp:CheckBoxList
I have a CheckBoxList and 5 labels. I would like the text value of
Suppose I have an SQL table entitled Facility which looks like this: || FacilityID
I have a CheckBoxList that displays a list of checkboxes using data from a

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.