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 KumarPosted May 8, 2017, 8:00 AM
athira kPosted May 8, 2017, 7:37 AM
Shubham KumarPosted May 8, 2017, 7:33 AM
Shubham KumarPosted May 8, 2017, 7:27 AM
Dharmraj ThakurPosted May 8, 2017, 7:21 AM
athira kPosted May 8, 2017, 5:51 AM
Dharmraj ThakurPosted May 8, 2017, 5:48 AM
athira kPosted May 8, 2017, 5:42 AM
Shubham KumarPosted May 8, 2017, 4:52 AM