i am a new developer for asp.net MVC. i have a edit button on gridview after click edit in popup model i can see every data. For example:
in my Db has customer table 4 columns: id(PK), Name, Surname, contact i can not see id textbox it is normal! but after clicking edit button Changing Name,SurName sending HttpPost Edit controller . there is a surprise event: ıd is disappear! After googling :
@using (Html.BeginCollectionItem("Kortingartikel")) {
@Html.HiddenFor(x => x.Artikelid)
@Html.TextBoxFor(x => x.Artikelnaam)
@Html.TextBoxFor(x => x.Prijs)
}
Hiddenfor is a solution. But the solution can not satisfy me . why id disappear and how to hold id value without hiddenfor?
This is not asp.net webform wich uses viewstate to store informations.
The MVC uses pure html without workaround.
So, basically, what it’s not in the post simply does not exists.
A way to not use the HiddenFor, that I can think of, could be to have your Id in the Url.
The Frmaework should be smart enough to bind it to a method like this