Adalat  Khan

Adalat Khan

  • 652
  • 1.5k
  • 866.7k

MVC Core Web Application

Sep 26 2018 7:56 PM
I have one Dropdown List and one TextBox control in my View. The Dropdown list contains branch codes and when i select the branch code i want to display its associated branch name in the TextBox control. I created the following action Method:
 
public string RerieveBranchName(string id)
{
var branchName = from e in dbContext.CompanyBranches
                               where e.BranchCode == id
                               select e;
ViewBag.SelectedBranchID = branchName.ToString();
return "0"; 
}
 
 Now my problem is how to pass the branch id to the action method when i select it from the dropdown list and after passing the branch id how to return the result and display in the TextBox.
 
Please help me. Thanks in advance
 
Please write your code in Razor syntax. Thanks again 

Answers (2)