I want to change the value in my EditorFor to a value from my DB, based on a selection from my DropDownFor.
Code to pull value to go into TextboxFor in my Controller
:
using (RexusTradingEntities RTE = new RexusTradingEntities())
{
if (PIVM.Pipe_Absolute_Roughness_Override != null || PIVM.Pipe_Absolute_Roughness_Override != 0)
{
PIVM.Pipe_Absolute_Roughness = Convert.ToDecimal(PIVM.Pipe_Absolute_Roughness_Override);
}
else
{
var PipeAbsoluteRoughness = (from P in RTE.ProjectInformations
join PM in RTE.PipeMaterials on P.Pipe_Material equals PM.Material_Name
where P.pkiProjectID == id
select PM).SingleOrDefault();
PIVM.Pipe_Absolute_Roughness = Convert.ToDecimal(PipeAbsoluteRoughness.Material_Value);
}
}
View:
@Html.EditorFor(model => model.Pipe_Absolute_Roughness, new { htmlAttributes = new { @class = "form-control col-md-5" } })
This works when loading the View the first time, but I want the value in the EditorFor to change when ever the DropDownFor selected value changes.
I would like this same EditorFor value to change when the following EditorFor Value changes :
@Html.EditorFor(model => model.Pipe_Absolute_Roughness_Override, new { htmlAttributes = new { @class = "form-control" } })
I would appreciate the help, as I am still pretty new to MVC and still learning the ropes.
Thanks for any help.