I have a bit confusion in a session where that how to fill the textbox on selection of an item from drop down list for that I have written the code that
controller
public async Task Index()
{
ViewBag.studentName = new SelectList(db.Students, "ID", "FirstName");
return View(db.Details.ToList());
}
view
$(document).ready(function () {
$('#StudentName').change(function () {
$('#Fee').val($(this).val());
alert(Fee);
});
});
@using (@Html.BeginForm("Edit", "StudentFee", FormMethod.Post))
{
@Html.AntiForgeryToken()
Agent Name
@Html.DropDownList("StudentName", (IEnumerable)@ViewBag.StudentName, "select value")
Fee
@Html.Editor("Fee", new { @class = "form-control" })
}
@Html.DisplayNameFor(model => model.StudentId) | @Html.DisplayNameFor(model => model.Date) | @Html.DisplayNameFor(model => model.Fee) | |
|---|---|---|---|
@Html.DisplayFor(modelItem => item.StudentId) | @Html.DisplayFor(modelItem => item.Date) | @Html.DisplayFor(modelItem => item.Fee) | @Html.ActionLink("Collect", "Edit", new { id = item.Id }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | @Html.ActionLink("Delete", "Delete", new { id=item.Id }) |

Shubham KumarRank #621 · 3.8K reputationPosted May 8, 2017, 12:52 AM EDT
athira k131 reputationPosted May 8, 2017, 1:42 AM EDT
Dharmraj ThakurRank #577 · 4.2K reputationPosted May 8, 2017, 1:48 AM EDT
athira k131 reputationPosted May 8, 2017, 1:51 AM EDT
Dharmraj ThakurRank #577 · 4.2K reputationPosted May 8, 2017, 3:21 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted May 8, 2017, 3:27 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted May 8, 2017, 3:33 AM EDT
athira k131 reputationPosted May 8, 2017, 3:37 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted May 8, 2017, 4:00 AM EDT