select index change example in dropdownlist in mvc

Posted by Klbaiju under ASP.NET MVC on 7/10/2018 | Points: 10 | Views : 383 | Status : [Member] | Replies : 1
Hi,

I have a table employee with Id,empname,salary,dept

I have creted and added the table in the application using Database fistmethod of EF.

I have populated id and empname in dropdownlist using

following code


public ActionResult Index()
{

var k = new SelectList(db1.MySkills.ToList(), "id", "EmpName");
ViewData["DBMySkills"] = k;
return View();
}

View

@Html.DropDownList("mySkills", ViewData["DBMySkills"] as SelectList, "Please Select an Employee" )

this is working fine.

my requirement is when I selects a name from dropdown ,I want to display id,empname,salary,dept in a table format.

is it possible other than jquery


Regards

Baiju




Responses

Posted by: Sheonarayan on: 7/10/2018 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Yes, add onchange event in the dropdown and using javascript write window.location.href = 'some action method', return ViewBag of the data that you want to return and populate it into the table.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response