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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:36:44+00:00 2026-06-11T14:36:44+00:00

I have a Generic List that it contains 4 value . how can I

  • 0

I have a Generic List that it contains 4 value .
how can I get my generic list values by index ? I want to get all values in generic list
this is my code :

var Checked = (form.GetValues("assignChkBx")).ToList();     
string str = "";
for (int i = 0; i < Checked.Count; i++)
{
    str = str + Checked[i]. +",";
} 

in this code I got all checkboxes values that checked . Now I want to get all values . how can I get 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-11T14:36:45+00:00Added an answer on June 11, 2026 at 2:36 pm

    Your question about the generic list is very misleading and I suspect that it has nothing to do with your real problem.

    Depending on how you generated the checkboxes inside your view that might be possible or not. If you hardcoded them using directly an <input type="checkbox"> tag values of checkboxes that were not checked will never be sent to the server – that’s how HTML checkboxes work. In this case you will not be able to get all values. If on the other hand you used the Html.CheckBoxFor helper to generate them then you will notice that this helper adds a hidden field to each checkbox in order to send all values. This helper operates on boolean values though.

    So I would recommend you creating a view model that will contain 2 properties: one holding the values you are interested in and one boolean property indicating whether the user selected this value or not in the view:

    public class ItemViewModel
    {
        public string Value { get; set; }
        public bool Checked { get; set; }
    }
    

    and then have a view model which has collection of those items:

    public class MyViewModel
    {
        public ItemViewModel[] Items { get; set; }
    }
    

    Now inside your view you can render those values like this:

    @model MyViewModel
    @using (Html.BeginForm())
    {
        for ( var i = 0; i < Model.Items.Length; i++)
        {
            <div>
                @Html.CheckBoxFor(x => x.Items[i].Checked)
                @Html.HiddenFor(x => x.Items[i].Value)
            </div>
        }
    
        <button type="submit">OK</button>
    }
    

    and finally inside the controller action that this form will be submitted to you will be able to get all values:

    [HttpPost]
    public ActionResult SomeAction(MyViewModel model)
    {
        foreach (var item in model.Items)
        {
            // here you could use item.Checked and item.Value
        }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question Updated I have a generic list which can contains the following values: Sector
I have a list that contains FrameworkElements and I want to create an extension
I have a generic list which can contain values in different languages based on
I have a generic linked-list that holds data of type void* I am trying
I have a class Team that holds a generic list: [DataContract(Name = TeamDTO, IsReference
I have two threads, a producer thread that places objects into a generic List
I have a generic Print method that iterates over a list and simply prints
I have generic list which must be a preserved order so I can retrieve
I have a Generic List object which hold below table as its own value.
I have a generic list. Some elements of this list belong to a parent

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.