Prasant Jinaga

Prasant Jinaga

  • 803
  • 750
  • 419.6k

Bind the value to the Model in MVC

Oct 1 2012 2:50 AM
Hi,

I have a grid like structure in one of my page 

In my Cshtml,

@Html.TextBoxFor(model => model.PatientPreferences[index].Email, new { @id = "patEmail" + index })

My Problem is,when is click on search button without entering any values it displays all the values and when i change something and click on update its also working fine.but when i enter some first name and click on search It displayed the corresponding row except Email field it remain the first value like '[email protected]' For a work around what i did,
i have changed my cshtml to 

 <input type="text" value="@Model.PatientPreferences[index].Email" />
@Html.TextBoxFor(model => model.PatientPreferences[index].Email, new { style = "display:none", @id = "patEmail" + index })

It works But wont be able to bind it to the model that is why its not updating...

Do anyone faced this problem ever???

Note:It works fine if change it from textbox to lable.

Answers (3)