Randy Rutecki

Randy Rutecki

  • 1.6k
  • 35
  • 2.9k

MVC Data Binding

Jul 8 2017 9:21 AM
I am trying to bind a value from a button to submit to a DB. I see that the view created a way to bind the value to a form textbox:
 
 @Html.EditFor(model => model.TeamNumber, New { htmlAttributes = new { @class = "form-control" } } )
 
 This works great if I wanted to add the TeamNumber in the textbox, but I have a series of buttons with the game schedule of teams for the week and when I click on one I am able to use jQuery to access the teamID's for the teams I want to select but need to save the selected teams to the db.
 
i have the db and class for 5 teams team1, team2 team3 etc. that I could save using the above binding but I want to know how to take the team1Id value from the button click and bind it to the model as if I had entered it in the text box.
 
Any help would be greatly appreciated.
Thanks
 

Answers (2)