How to bring the employee name list in one column on selection of project name drop-down list? At the same time while besides employee name 1 textbox and one date filterbox also should generate dynamically. I'm am not good in scripting technologies need some guidance.
1 Answers
Here's how I would do it, if anyone has any criticisms please let me know!
In your controller action for the page return a list of Project objects in a View Model. Each Project object should have at least two properties; one for the name and one for a unique ID. In the Razor view for the page, render the Project objects via a the DropDownList HTML Helper.
Next, set up a Web API endpoint for retrieving a list of Employee's based on the Project they are assigned to.
In your Razor page which displays the lists, write some JavaScript which executes on change of the value of the Project DropDownList. The JavaScript should take the updated value of the Project dropdown, use this value to call the Web API endpoint for retrieving Employee's (based on Project ID), and render the resulting data in a HTML select element.

- 429
- 1
- 5
- 11
-
Thanks for the quick reply, the drop down I made it and project name is coming and on selection change its calling the method for employee ID method also but in the API side I'm getting always null even I wrote Linq to get the proper mapping with my project with employee table. I'm not able to hit my API in debug mode. Any suggestions for that – Dev Sahu Aug 16 '19 at 13:05
-
@DevSahu Where are you getting null? You should be able to hit the API endpoint in debug mode, what is displayed if you try to hit the endpoint? – Fraser Aug 16 '19 at 13:09
-
Null reference even in postman 404 error is coming I cross checked everything paramaer name and url is correct in apihelper class get url also correct but result and response I'm getting null Var req= client.GetAsync(strURL). Result here req is coming null for me. – Dev Sahu Aug 16 '19 at 13:20
-
Check to see that your routing is set up correctly for your API. If you can update your post to include any code segments it would really help. – Fraser Aug 16 '19 at 13:29
-
this is belongs to portal method[HttpGet] public ActionResult GetProjectByID(int ID) { ProjectMasters model = new ProjectMasters(); if (ID != 0) { model = APIHelper.Instance.GetData
(AppConfiguration.ResourceReleaseAPIURL() + "GetProjectMaster?id=" + ID); } return PartialView("_ResourceRelease", model); } – Dev Sahu Aug 16 '19 at 14:32