Class User.cs, property user_id. If I remove EditorFor for user_id from the View, user_id is null after the Edit view posts results back to controller.
How do I keep user_id value after loading Edit View if I don't put EditorFor in the View for this field? In this case the Edit action returns null reference error. I want to somehow store the user_id value before loading the View and then regardless of what is entered in the View I want to restore this user_id value from the previously saved place and update the database record by this id.
The problem is that MVC doesn't want to see anything in the View except EditorFor.
DisplayFor, TextBoxFor are not accepted, all give null in the result. HiddenFor is not the choice because it still loads the id to the page. EditorFor can't be set to readonly. So I want to remove it at all but keep user_id somehow in the model.
EDIT
Looks like TempData is not a safe place. Can it be done by making a derived class with some additional properties where the id can be reserved for awhile? Idk about classes too much