【发布时间】:2014-06-16 18:37:52
【问题描述】:
我有一个 ASP.NET 项目,并且有一些复选框可以选择重复。我想将其转换为将显示它的字符串。
一个简单的版本是
创建.cshtml
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<p style="font-weight:bold">New Record</p>
<div id="date">
<input type="checkbox" value="Sunday" />Sunday
<input type="checkbox" value="Monday" />Monday
<input type="checkbox" value="Tuesday" />Tuesday
...
</div>
<p>
<input type="submit" value="Create" />
</p>
<div align="left">
<font color="black" size="4" > @Html.ActionLink("<<Back to List", "Index", "Home", null, null)</font>
</div>
</fieldset>
}
我想将它作为一个简单的字符串保存在模型中,例如“1011011”
标准创建函数
[HttpPost]
public ActionResult Create(Event event)
{
if (ModelState.IsValid)
{
using (var context = new EventDBContext())
{
context.RecordList.Add(event);
context.SaveChanges();
}
return View("Index");
}
return View("Error");
}
这样做的正确方法是什么?
【问题讨论】:
标签: c# asp.net asp.net-mvc