我的视图中有一个下拉列表
<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>
有这个模型
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; }
}
}
通过此控制器出现在视图中
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();
}
这些是下拉列表中显示的 suprocesses
Past due collection
Dealer audits
Credit Watch classification
Reconciliation
Control
每个子进程都可以拥有进程
Portfolio Management
Finance
Test Modeling
现在我被要求在下拉列表中显示的不是子进程名称,而是
"<process name> - <subprocess name>"
Portfolio Management - Reconciliation, for example
我有最微弱的想法如何做到这一点。有任何想法吗??