保存选中的字段,就像在网上商店中一样
Saving checked fields, like in Online Shop
我正在尝试执行结帐之类的操作。在网上商店。我正在从数据库中获取列表,我想将选定的列表发送到其他视图。
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<fieldset>
<div class="clstable">
<table id="table" border="0" style="width:60%">
<tbody>
@foreach (var item in Model)
{
<tr>
<td name="Sub">@item.Name</td>
<td>
<input name="Nam" type="number" min="0" width="10" />
</td>
<td align="center"><input name="Check" type="checkbox" padding-left 5px; /></td>
</tr>
}
</tbody>
</table>
<button type="submit" aligh="center">Submit/Buy</button>
</div>
</fieldset>
public class DBData
{
public string Name { get; set; }
public string Subscription { get; set; }
}
[HttpGet]
public ActionResult About()
{
var subscriptions = new List<DBData>();
using (var db = new OnePortalVsEntities())
{
...
}
return View(subscriptions);
}
如何将选定的 Sub 及其编号(在输入编号中选择)获取到其他视图?
我应该创建一个会话还是 post 以某种方式全部控制?
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<fieldset>
<div class="clstable">
<table id="table" border="0" style="width:60%">
<tbody>
@for (int i = 0; i < Model.Count(); i++ )
{
<tr>
<td name="Sub">@Model[i].Name</td>
<td>
<input name="Nam" type="number" min="0" width="10" />
</td>
<td align="center">@Html.CheckBoxFor(x=>x[i].BoolProperty)</td>
</tr>
}
</tbody>
</table>
<button type="submit" aligh="center">Submit/Buy</button>
</div>
</fieldset>
}
您还错过了 <tbody>
标签。
我正在尝试执行结帐之类的操作。在网上商店。我正在从数据库中获取列表,我想将选定的列表发送到其他视图。
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<fieldset>
<div class="clstable">
<table id="table" border="0" style="width:60%">
<tbody>
@foreach (var item in Model)
{
<tr>
<td name="Sub">@item.Name</td>
<td>
<input name="Nam" type="number" min="0" width="10" />
</td>
<td align="center"><input name="Check" type="checkbox" padding-left 5px; /></td>
</tr>
}
</tbody>
</table>
<button type="submit" aligh="center">Submit/Buy</button>
</div>
</fieldset>
public class DBData
{
public string Name { get; set; }
public string Subscription { get; set; }
}
[HttpGet]
public ActionResult About()
{
var subscriptions = new List<DBData>();
using (var db = new OnePortalVsEntities())
{
...
}
return View(subscriptions);
}
如何将选定的 Sub 及其编号(在输入编号中选择)获取到其他视图? 我应该创建一个会话还是 post 以某种方式全部控制?
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<fieldset>
<div class="clstable">
<table id="table" border="0" style="width:60%">
<tbody>
@for (int i = 0; i < Model.Count(); i++ )
{
<tr>
<td name="Sub">@Model[i].Name</td>
<td>
<input name="Nam" type="number" min="0" width="10" />
</td>
<td align="center">@Html.CheckBoxFor(x=>x[i].BoolProperty)</td>
</tr>
}
</tbody>
</table>
<button type="submit" aligh="center">Submit/Buy</button>
</div>
</fieldset>
}
您还错过了 <tbody>
标签。