I want to create a modal box which has the Title of a Product associated to the button next to the Product when clicked. The data is coming from a database.
I am currently trying to use an integer, which increments on each record in the table, and use this integer to get the record Title. However, I have been unsuccessful to print the currently iterated product.
I'm using bootstrap stylesheets.
Here is a snippet of my code
foreach (var item in Products)
.. display Title, Description, Price, button & modal code
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal_@i"> View Product</button>
<div class="modal fade" id="myModal_@i" role="dialog" data backdrop="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">View Product</h4>
---> @Html.DisplayFor(modelItem => Model.Products.ElementAt(i)) ????
</div>
<div class="modal-body" id="@i">
Any help would be greatly appreciated.