Help looping through table rows and saving selected to an object in ASP.NET MVC
I am trying to figure out what the best way to save values to my database based on whether or not a 开发者_如何学JAVArow's checkbox in a table is checked or not.
In my ASP.NET MVC application that I am trying to save a selected row (a location) to a "locationtemplate" object.
What I want to be able to do is for each selected row (a location) in the table on my view, save it to the locationtemplate object. I am not sure where I should perform the check on whether the row is selected or not.
View Code (so far):
foreach(var locationTemplateLocationRow in Model.LocationTemplateLocationRows)
{
<tr>
<td><input type="checkbox" name="LocationToAdd"/></td>
<td><%= locationTemplateLocationRow.Name%></td>
<td><%= locationTemplateLocationRow.LastDateSent%></td>
</tr>
}
Based on what is selected I would like to send my list of checked locations to my save action on my controller and go from there.
Any help would be greatly appreciated.
what i understand is that you want to bind to a list object (locationTemplate) where each object will contain a boolean property to hold value of checkbox. For this purpose plz go through this tutorial
精彩评论