Unfortunately I can not write complete code for you neither anyone else will but I can tell you the steps to achieve what you need.
1. Create a method inside the controller with return type as JsonResult. Foe example:
public JsonResult GetValuesFromDatabase(int inputId)
2. Perform Database query in the method and return something like:
public JsonResult GetValuesFromDatabase(int inputId){
var firstValue = "Value for TextBox1";
var secondValue = "Value for TextBox2";
var jsonData = new
{
value1: firstValue,
value2: secondValue
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
3. Since you have already written "onchange" event for your dropdownlist, you will have to implement that function somehere on your view(a seperate JS file would be better). For example:
function copyValue1(){
$.ajax({
type: "GET",
url: "/YourControllerName/GetValuesFromDatabase",
dataType: "Json",
data: { inputId: $("#YourDropdownList").val()},
success: function (response) {
$("#Textbox1").val(response.value1);
$("#Textbox2").val(response.value1);
}
});
}
Hope it helps.