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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:35:43+00:00 2026-05-31T23:35:43+00:00

I have a problem trying to edit. I work with Areas for better management

  • 0

I have a problem trying to edit. I work with Areas for better management the application.The problem is in the areas called “Administrator”.

Next is the controller code (OfficeControlle), I use a session variable has been previously created and functions to edit the model data I get.

public ActionResult Edit()
        {
            decimal id;
            id = (decimal)Session["consul"];
            CAMPUS_UNIVERSITY campus_university = db. CAMPUS_UNIVERSITY.Single(s => s.Idoffice == id);
            ViewData.Model = db.OFFICE.Single(c => c.Idoffice == id);
            ViewBag.University = db.UNIVERSITY.Single(u => u.IdUniversity == campus_university.IdUniversity);
            ViewBag.campus = db.CITY_CAMPUS.Single(u => u.IdCity == campus_university.Idcitycampus);
            return View(sede_universidad);
        }

         [HttpPost]
        public ActionResult Edit(CAMPUS_UNIVERSITY campus_university, OFFICE office)
        {
            if (ModelState.IsValid)
            {
                db.CAMPUS_UNIVERSITY.Attach(campus_university);
                db.ObjectStateManager.ChangeObjectState(campus_university, EntityState.Modified);
                db.SaveChanges();

                db. OFFICE.Attach(office);
                db.ObjectStateManager.ChangeObjectState(office, EntityState.Modified);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            ViewBag.IdCitycampus = new SelectList(db.CITY_CAMPUS, "IdCity", "Name", campus_university.IdCitycampus);
            ViewBag.IdConsultorio = new SelectList(db.OFFICE, "Idoffice", "addressoffice", campus_university.Idoffice);
            ViewBag.IdUniversidad = new SelectList(db.UNIVERSITY, "IdUniversity", "Name", campus_university.IdUniversity);
            return View(campus_university);
        }

Next is the view code

@model RolMVC3.Models.CAMPUS_UNIVERSITY

@{
    ViewBag.Title = "Edit"; 
}

<h2>edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <h2> @ViewBag.University.Name - @ViewBag.Campus.Name </h2>

    <fieldset>
        <legend>OFFICE</legend>

        @Html.HiddenFor(model => model.IdUniversity)

        @Html.HiddenFor(model => model.IdCitycampus)

        @Html.HiddenFor(model => model.Idoffice)

        <div class="editor-label">
            @Html.LabelFor(model => model.addresscampus)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.addresscampus)
            @Html.ValidationMessageFor(model => model.addresscampus)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.phonecampus)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.phonecampus)
            @Html.ValidationMessageFor(model => model.phonecampus)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.emailcampus)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.emailcampus)
            @Html.ValidationMessageFor(model => model.emailcampus)
        </div>

        <fieldset>
        <legend>OTHER DATE</legend>
        @Html.Partial("_office", Model.OFFICE)
        </fieldset>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("back", "Index")
</div>

The problem appears when I press the “Save” button, get the following error:

The parameters dictionary contains a null entry for parameter ‘Id’ of non-nullable type ”System.Decimal’ ‘ for method ”System.Web.Mvc.ActionResult Index(System.Decimal)’ in ”RolMVC3.Areas.Administrator.Controllers.OfficeController”

  • 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-31T23:35:44+00:00Added an answer on May 31, 2026 at 11:35 pm

    When you are redirecting here:

    return RedirectToAction("Index");
    

    make sure that you pass the id in the query string as it looks like your Index action requires it as parameter:

    return RedirectToAction("Index", new { id = campus_university.IdUniversity });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have problem with errorPlacement, I'm trying to place the error message next
I have a problem when trying to execute this update statement (below) using C#
Hey all, i have a problem with trying to get 2 forms to close
I have a problem I'm trying to solve involving interfaceing a C++ program with
I have run into a problem trying to modify a form I myself have
Ok I have this problem I'm trying to use Jquery to load a partial
I have a problem when I'm trying to delete an image file. I always
I have this problem I've been trying to tackle for a while. I have
I have big problem when I am trying to deploy my app over clickonce.
I have a problem with a page where I am trying to get colorbox

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.