所以我的显示模板中有这段代码:
@Html.DropDownListFor(blah => blah.InputtedData, ddv)
我得到一个实际的下拉列表。我试过这段代码:
@Html.DisplayFor(blah => blah.InputtedData, ddv)
我得到1
(第一名),selectedvalue。但我想显示Yes
选定的文本。那么如何在显示模板的下拉列表中显示选定的文本而不是选定的值?
根据请求:
namespace TESTMVC.ViewModels
{
public class CtrlInputDataModel
{
public CtrlTypeModel RowCtrl { get; set; }
public long InputtedDataID { get; set; }
public string InputtedData { get; set; }
public DateTime InputtedDate { get; set; }
public CtrlInputDataModel()
{
}
public CtrlInputDataModel (CtrlTypeModel newRowCtrl, long newInputtedDataID, string newInputtedData, DateTime newInputtedDate)
{
RowCtrl = newRowCtrl;
InputtedDataID = newInputtedDataID;
InputtedData = newInputtedData;
InputtedDate = newInputtedDate;
}
}
}
ViewModelddv
基于:
namespace TESTMVC.ViewModels
{
public class DefaultValueModel
{
public string Label { get; set; }
public string Value { get; set; }
public DefaultValueModel()
{
}
public DefaultValueModel(string newLabel, string newValue)
{
Label = newLabel;
Value = newValue;
}
}
}