I have a dropdowlist in my view
<div class="editor-label">
@Html.LabelFor(model => model.SubProcessId, "SubProcess")
</div>
<div class="editor-field">
@Html.DropDownList("SubProcessId", ViewBag.SubProcessId as SelectList)
@Html.ValidationMessageFor(model => model.SubProcessId)
</div>
That has this model
namespace CTTModel
{
using System;
using System.Collections.Generic;
public partial class **SubProcess**
{
public SubProcess()
{
this.Risks = new HashSet<Risk>();
}
public int Id { get; set; }
public string Name { get; set; }
public int ProcessId { get; set; }
public string Description { get; set; }
public virtual **Process** Process { get; set; }
public virtual ICollection<Risk> Risks { get; set; }
}
}
which appears in the view via this controller
public ActionResult Create()
{
try
{
// Risk
**ViewBag.SubProcessId = new SelectList(_db.SubProcesses, "Id", "Name", "Process");**
ViewBag.RiskSeverityId = new SelectList(_db.RiskSeverities, "Id", "Name");
ViewBag.RiskFrequencyId = new SelectList(_db.RiskFrequencies, "Id", "Name");
ViewBag.RiskRatingId = new SelectList(_db.RiskRatings, "Id", "Name");
ViewBag.RiskType1Id = new SelectList(_db.RiskType1, "Id", "Name");
ViewBag.RiskType2Id = new SelectList(_db.RiskType2, "Id", "Name");
//Test
ViewBag.RegionLevelId = new SelectList(_db.RegionLevels, "Id", "Name");
}
catch (Exception ex)
{
throw;
}
return View();
}
These are the suprocesses that show in the dropdownlist
Past due collection
Dealer audits
Credit Watch classification
Reconciliation
Control
Every sub process can have on process
Portfolio Management
Finance
Test Modeling
Now I was asked to show in the dropdownlist not the subprocess name, but instead
"<process name> - <subprocess name>"
Portfolio Management - Reconciliation, for example
And I have the faintest idea how to do that. Any ideas??