I asked a question yesterday about how to fix a sudden and unexpected "Object not set to an instance of an object" error. The only real answer I got was to pass a new instance of the object to the view like this:
// GET: WC_Inbox/Create
public ActionResult Create(int? id)
{
System.Diagnostics.Debug.WriteLine("Employee ID was: " + id);
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Employee employee = db.Employees.Find(id);
if (employee == null)
{
return HttpNotFound();
}
string fullName = employee.First_Name + " " + employee.Last_Name;
System.Diagnostics.Debug.WriteLine("Employee full name: " + fullName);
ViewBag.EmployeeID = id;
ViewBag.Name = fullName;
ViewBag.Status = "Pending";
return View(new WC_Inbox());
}
With the primary line in question being here: return View(new WC_Inbox());
This worked, however it has created further issues. Now on my create page I am given some incorrect data in some fields
The fields Org Number, Hire Date, Work Schedule, and Injury date should not show those values. Those are incorrect and will be very confusing to the mostly elderly client bass the app is intended for. I would like for the placeholder values to show up there rather than this incorrect data.
This is the code from the Create view for those fields:
<div class="form-group">
@Html.LabelFor(model => model.Org_Number, "Org Number", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Org_Number, new { htmlAttributes = new { @class = "form-control", placeholder = "0025" } })
@Html.ValidationMessageFor(model => model.Org_Number, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Hire_Date, "Hire Date", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Hire_Date, new { htmlAttributes = new { @class = "form-control", placeholder = "8/3/2021" } })
@Html.ValidationMessageFor(model => model.Hire_Date, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job_Title, "Job Title", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Job_Title, new { htmlAttributes = new { @class = "form-control", placeholder = "Programmer Analyst" } })
@Html.ValidationMessageFor(model => model.Job_Title, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Work_Schedule, "Work Schedule", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Work_Schedule, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Work_Schedule, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injury_Date, "Injury Date", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Injury_Date, new { htmlAttributes = new { @class = "form-control", placeholder = "8/14/2021" } })
@Html.ValidationMessageFor(model => model.Injury_Date, "", new { @class = "text-danger" })
</div>
</div>
How can I get rid of that bad data and use the placeholder values I assigned instead?
PS: Work Schedule should simply be blank. There is no placeholder value.

WC_Inboxobject to the view. It is necessary to populate it with some data beforereturn View(...);