3
我在工具上工作,所以我可以保持组织在游戏中的东西。多选择枚举
这是我的课:
//The item
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Value { get; set; }
public ItemLabel Label { get; set; }
public ItemType Type { get; set; }
public ItemTradeType TradeType { get; set; }
public Trade Trade { get; set; }
}
的Label/Type/TradeType/Trade
是枚举。
查看:
@model EveMonitorV2.Models.Item
@{
ViewBag.Title = "AddItem";
}
<h2>AddItem</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Item</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Value)
</div>
//What should be done here?
<div class="editor-field">
@Html.EditorFor(model => model.Value)
@Html.ValidationMessageFor(model => model.Value)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Trade)
</div>
<div class="editor-field">
@Html.CheckBoxFor()
@Html.ValidationMessageFor(model => model.Trade)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
枚举有可能整个列表,我想打一个项目创建视图
我碰到的问题:
我希望能够到从枚举中选择更多选项。 (Like this) 其中类别是我的枚举。
这是可能的所有在asp.net mvc 4?
(小注:我还是个学生,但它不是一个学校项目)
您可以使用System.Enum类来获取Enum的名称和值(例如, http://msdn.microsoft.com/en-us/library/system.enum.getvalues.aspx)。循环播放这些内容并为每个值创建一个Html.CheckBox。 – kevingessner
谢谢@kevingessner我会检查出来的 – JochemQuery