first you create method to get dropdwon list data in your controller like this
public ActionResult GetStudent(int id)
{
var div = (from s in demoContext.Student_db
where s.RollNumber == id
select s.Div).FirstOrDefault();
return Content(div);
}
then create view like this
@{
ViewBag.Title = "FillDropDwon";
}
<pre lang="SQL"><h2>FillDropDwon</h2>
@Html.DropDownList("StudentsList", Model.Drp_Names, "Select", new {onchange="GetDiv()"})
and finally create jqurey to bind dropdwon list like this
<script>
function GetDiv() {
var rollNumber = $('#StudentsList').val();
$.ajax(
{
type: "POST",
url: "@Url.Action("GetStudent","Home")",
dataType: 'text',
data: { id: rollNumber },
success: function (result) {
$('#myTextBox').val(result);
},
error: function (req, status, error) {
alert("Coudn't load partial view"+error+req);
}
});
}</script>
hope this is helpfully