I have an Index page which lists some records in a table.
Now in each of these records I have added a DropDownList and what I want is when you select the record using the ActionLink on the side to send not only the ID of the record but the ID of the selected Value from the DropDownList as well.
Could you please advise?
<script type="text/javascript">
$(document).ready(function () {
$("#LoanId").change(function () {
var selectedLoan = $("#LoanId option:selected").val();
});
});
</script>
@model IEnumerable<Project.ViewModels.BrowseTemplates>
@{
ViewBag.Title = "Index";
}
<h2>Available Templates </h2>
<script src="~/Scripts/jquery-3.1.1.js"></script>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.TemplateLanguage.TemplateType.TemplateTypeName)
</th>
<th>
@Html.DisplayNameFor(model => model.TemplateLanguage.Language.LanguageName)
</th>
<th>
@Html.DisplayNameFor(model => model.TemplateName)
</th>
<th>
@Html.DisplayNameFor(model => model.TemplateLanguage.TemplateType.Category.CategoryName)
</th>
<th><label>Loan</label></th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.TemplateLanguage.TemplateType.TemplateTypeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TemplateLanguage.Language.LanguageName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TemplateName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TemplateLanguage.TemplateType.Category.CategoryName)
</td>
<td>
@Html.DropDownList("Loans", null, "Please Select", htmlAttributes: new { @class = "form-control", style = "width:200px", @id="LoanId" })
</td>
<td>
<div id="LinkDiv">
@Html.ActionLink("Generate Document", "Create", "Documents", new { TemplateId = item.ID, LoanId = item.LoanId }, null)
</div>
</td>
</tr>
}
</table>
idattributes in your<select>)