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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:49:04+00:00 2026-06-14T16:49:04+00:00

I changed my index view so that each row is wrapped in a form:

  • 0

I changed my index view so that each row is wrapped in a form:

Index.cshtml

@model IEnumerable<LevEl.Models.Page>

@foreach (var item in Model)
{
  using (Html.BeginForm("Edit", "Pages", item, FormMethod.Post, new { id = "itemForm_" + item.PageId }))
  { 
  <tr>
    <td>
      @Html.DisplayFor(modelItem => item.Title)
    </td>
    ...
    ... more fields
    ...
    <td>
      @Html.CheckBoxFor(modelItem => item.IsPublished, new { onClick = "$(itemForm_" + item.PageId + ").submit();" })
    </td>
    <td>
      @Html.ActionLink("Edit", "Edit", new { id = item.PageId }) | @Html.ActionLink("Details", "Details", new { id = item.PageId }) | @Html.ActionLink("Delete", "Delete", new { id = item.PageId })
    </td>
  </tr>
  }
}

Here’s my controller:

PagesController.cs

public ActionResult Index()
{
  return View(db.Pages.Include(p => p.Language).ToList());
}

[HttpPost]
public ActionResult Edit(Page page)
{
  var method = Request.HttpMethod;

  if (ModelState.IsValid)
  {
    if (page.PageContents.GroupBy(pc => pc.Language).Any(g => g.Count() > 1))
      return HttpNotFound("A page cannot have two translations in the same language.");

    db.Entry(page).State = EntityState.Modified;
    db.SaveChanges();
    ClearMenuKeys();
    return RedirectToAction("Index");
  }
  return View(page);
}

When I switch the value in the check box and the controller is reached, page is null.
How can I pass the entire page object upon postback?

  • 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-14T16:49:05+00:00Added an answer on June 14, 2026 at 4:49 pm

    It seems to me like your HTML do not store values of the Page. @Html.DisplayFor only displays data you have to set @Html.HiddenFor for that field too.

    EDIT:

    @Html.DisplayFor(modelItem => item.Title)
    @Html.HiddenFor(modelItem => item.Title)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following view that has tow dropdowns and one button: @model RoomReservation.Webb.Models.HomeViewModel
I'm editing multiple instances of a parent model in an index view in one
I have a view in my app that uses a @modeltype ienumerable of (xxxxxxx.abc),
I wanna make a page that contains more than one tables. Each table is
I have this line in my View <h1 > Reply to: @Model.dialogueEntity[index].DialogueSubject</h1> and I
I have an index page that lists all users. This has the following in
How can i change image index of a tree view node in a threadsafe
Hi need to change the selected index of a when another has been changed..
In my ASP.NET MVC 3 app I have a page where, after its form
ok here is the thing i have the view store that shows all the

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.