You have 2 textboxes one for id and another for showing name based on the id. Here the best solutions will be to use jQuery AJAX. This is how to proceed.
1. On the first textbox keydown event make jQuery AJAX to call C# function on your Controller.
2. This C# function will receive the id and will fetch the name from the database based on this id and will return the name at the end.
3. You will then show that name on your name textbox.
The you will first apply .keydown() event on your id textbox like this:
$( "#idtextbox" ).keydown(function() {
});
For making AJAX call you can use
AJAX Method or
jQuery Load.
You can also check this
CodeProject Article that does ajax call in MVC application.