Hi
I have below Html. I want is user clicked Current i want to display Current Employer name.
If Previous is selected then Previous Employer Name from Database using LInq.
Code
Current
PreviousThanks
Hi
I have below Html. I want is user clicked Current i want to display Current Employer name.
If Previous is selected then Previous Employer Name from Database using LInq.
Current
PreviousThanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Oct 10, 2022, 4:36 AM EDT
string _employeeType = "Current"; var _result = Employees.Where(whr=> whr.EmployeeType == _employeeType).Select(sel=> sel.EmployeeName).FirstorDefault();Ramco RamcoRank #462 · 5.4K reputationPosted Oct 10, 2022, 4:49 AM EDT
Hi Vishal
How i will handle click option. If user clicked Current i want to display Current Employer name.
If Previous is selected then Previous Employer Name .
Thanks
Vishal YelveRank #178 · 13.6K reputationPosted Oct 10, 2022, 4:56 AM EDT
Hi Ramco,
In HTML on the dropdown change, you need to make an ajax call. and from the controller, you can return employeename
On HTML by AJAX call $(function () { $('.current_subscription_col').change(function () { var _employeeType = this.Text(); $.ajax({ url: "Home/GetEmployeeName", data: { employeeType: _employeeType }, type: "GET", success: function (response) { if (response != null) { alert("Name : " + response.EmployeeName); } }, error: function () { alert("Error"); } }); }); }); // In Controller [HttpGet] public async Task GetEmployeeByEmployeeType(string employeeType) { var _result = Employees.Where(whr=> whr.EmployeeType == employeeType).Select(sel=> sel.EmployeeName).FirstorDefault(); return Json(_result); }Vishal YelveRank #178 · 13.6K reputationPosted Oct 10, 2022, 4:59 AM EDT
Please change this
in HTML
and in JavaScript
change $('.current_subscription_col') to $('#ddlEmployeeType').