1
I have a View
, where the user must fill in some fields, and has a last field that I left him disable
, and would like that in this field appears the name of the user, but how do I fill?
Model
:
public class CombustivelModels
{
[Key]
public int CombustivelId { get; set; }
[Required]
public decimal km_inicial { get; set; }
[Required]
public decimal km_final { get; set; }
[Required]
public decimal litros { get; set; }
[Required]
[DataType(DataType.Currency)]
public decimal valor { get; set; }
[Required]
public string UserId { get; set; }
}
View
:
<div class="form-group">
@Html.LabelFor(model => model.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => User.Identity.Name, new { htmlAttributes = new { @class = "form-control", @disabled=""} })
@Html.ValidationMessageFor(model => model.UserId, "", new { @class = "text-danger" })
</div>
</div>
Example:
But when trying to save:
Man, I get it, but I don’t know how to fix it, you could point me out, or improve your answer?
– Thomas Erich Pimentel
@Thomaserichpimentel take a look and see if it got better.
– Ricardo
Perfect. Thank you very much.
– Thomas Erich Pimentel