I have spent years mostly working in classic asp and am finally trying to come into the .net world. I have multiple items I need assistance with.
1) The create view has a drop down in it. Right now it is populated with all records in the table but only some of them should be shown. I have a stored procedure that is normally used to populate the drop down list, but do not know how to change it in the code to use the procedure. The class for the procedure shows
namespace AMS_MVC.Models
{
using System;
public partial class usp_ListRoles_Result
{
public byte RoleID { get; set; }
public string RoleName { get; set; }
}
}
here is what the controller has right now (generated by visual studio) using entity
ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "RoleName");
2) I do not want the first item in the list to be a default, I prefer to have the first item say "Make Selection" and not have a value. Therefore the administrative user cannot make a mistake and assign a person to the wrong role by forgetting to make a selection.
3) I need to add an onChange event to the drop down. Depending on the role selected, other options may be shown. For example if the role of department manager is selected then it should display a drop down list of departments, If the role of district manager is selected then it would display a list of districts etc.. In one option Location Department Manager it should display both a list of departments and also a list of locations.
In classic asp the onchange event calls a javascript function which i wrote that displays the correct hidden div(s).
Please people, I have been looking at many different example for a week now on this site as well as on others provided by google and bing searches and they are no help. if all you want to do is point to someone else's question that answers something similar but not exactly what I am looking for then please don't provide a link because it does not help me.