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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:57:48+00:00 2026-05-30T05:57:48+00:00

I have a view model which is just public class Visits { public List<Visit>

  • 0

I have a view model which is just

public class Visits
{
    public List<Visit> visits { get; set; }
}

In my visit model I have a

public bool ValidVisit { get; set; }

I am able to pass everything to my view ok and render all of the visits on the view. The view looks like

@model TheWallSite.ObjectModels.Visits

@{
    ViewBag.Title = "Potential invalid visits!";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
       <fieldset>
        <table>
            <tr><th>Check In/Out Time</th><th>Visit Type</th><th>In/Out</th><th>IP</th><th>SSO ID</th><th>Valid Visit</th></tr>

            @foreach (var item in Model.visits)
            {
                <tr>
                    <td>@Html.DisplayFor(model => item.InOutTime)</td>
                    <td>@Html.DisplayFor(model => item.VisitType)</td>
                    <td>@Html.DisplayFor(model => item.VisitName)</td>
                    <td>@Html.DisplayFor(model => item.IP)</td>
                    <td>@Html.DisplayFor(model => item.SSO)</td>
                    <td>@Html.EditorFor(model => item.ValidVisit)</td>
                </tr>
            }
        </table>
        <input type="submit" value="Submit" />
       </fieldset>
}

The problem I am having is I want the end user to be able to check/uncheck the ValidVisit and then pass these back to the controller and make the correct changes in my database.. I am having a heck of a time figuring out how to do this. Any suggestions? My [HttpPost] controller signature is

public ActionResult ListQuestionableVisits(Visits model, FormCollection forms)

but nothing seems to be getting back to the controller.

  • 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-30T05:57:49+00:00Added an answer on May 30, 2026 at 5:57 am

    It would be the model-binding not kicking in, probably due to the loop.

    I know i know, it should work, but do it the right way, and it has a better chance of working.

    Try using editor templates instead.

    /EditorTemplates/Visit.cshtml

    @model TheWallSite.ObjectModels.Visit
    <tr><td>@Html.DisplayFor(model => model.InOutTime)</td></tr>
    <tr><td>@Html.DisplayFor(model => model.VisitType)</td></tr>
    <tr><td>@Html.DisplayFor(model => model.VisitName)</td></tr>
    <tr><td>@Html.DisplayFor(model => model.IP)</td></tr>
    <tr><td>@Html.DisplayFor(model => model.SSO)</td></tr>
    <tr><td>@Html.EditorFor(model => model.ValidVisit)</td></tr>
    

    Main View:

    @model TheWallSite.ObjectModels.Visits
    
    @{
        ViewBag.Title = "Potential invalid visits!";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    @using (Html.BeginForm())
    {
           <fieldset>
            <table>
                <tr>
                   <th>Check In/Out Time</th>
                   <th>Visit Type</th>
                   <th>In/Out</th>
                   <th>IP</th>
                   <th>SSO ID</th>
                   <th>Valid Visit</th>
                </tr>                
                @Html.EditorFor(model => model.Visits)
            </table>
            <input type="submit" value="Submit" />
           </fieldset>
    }
    

    Also, if that’s your complete view, you don’t need the FormCollection parameter in the action, unless there is a hidden field/some other magic field i’m not seeing.

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

Sidebar

Related Questions

Consider the following model: public class BandProfileModel { public BandModel Band { get; set;
I have a view model with a property Fields which is an ObservableCollection<FieldVM> .
In my view model if have a: List<Car> where car has an Id and
I have a domain data model which returns a class such as the following:
I'm building an asp.net MVC 2 app. I have a list view which lists
Item is a simple model class. ItemComponent is a view for an Item which
I have a very simple viewmodel class, and a strongly typed view (which uses
I have a custom struct called TimeOfDay which is used in a view model
any help with this would be great. I have a model public class Master
I have the following classes: public class Note { public string Text { get;

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.