ビューに 2 つのモデルを渡したい。これらのテーブルの両方のフィールドに入力します。
それが正しいか?
// public ActionResult checkout(string usernam)
//{
// ViewBag.username = usernam;
//using( var db=new myProjectContext())
//{
// var tuple = new Tuple<tbl_Order, tbl_purchase>(new tbl_Order(),new tbl_purchase());
// return View(tuple);
// }
// }
[HttpGet]
public ActionResult checkout(string usernam)
{
ViewBag.username = usernam;
var FeacherToTwoModel = new ViewModelX() ;
return View(FeacherToTwoModel);
}
[HttpPost]
public ActionResult checkout(ViewModelX model)
{
if (ModelState.IsValid)
{
UsersClass.InsertInOrderAndBasket(model.tbl_order.id, model.tbl_ order.id_Type, model.tbl_ order.username,model.tbl_basket.username, model.tbl_basket.id_order);
}
else
{
}
return View();
}
とビューで:
// @model Tuple<myProject.Models.tbl_Order, myProject.Models.tbl_purchase>
//<label class="checkbox payment-method inline">
// @Html.CheckBoxFor(tuple => tuple.Item1.TypeCheck)remember me</label>
// .
// .//other fields
// .
.
.
.
<div id="collapseFour" class="accordion-body collapse">
<div class="accordion-inner">
@model MyProject.Models.ViewModelX
<p>please select a style</p>
<label class="checkbox payment-method inline">
@Html.CheckBoxFor(m => m. )remember me </label>
<label class="checkbox payment-method inline">
@Html.CheckBoxFor(m => m. )
online
</label>
<form class="form-inline">
<input class="input-block span4" placeholder="Enter your coupon code here" type="text" id="couponcode">
<button type="submit" class="btn btn-general">register</button>
</form>
</div>
</div>
.
.
.
<tbody>
@model IEnumerable<MyProject.Models.vw_basket>
@foreach (var item in Model)
{
<tr>
<td class="image"><a href='../Kala/Product?NID=@item.id_kala'>
<img '@item.comment' alt='@item.name_product' src="~/Content/Media/Images/product/@MyProject.Models.ProductClass.GetPicById_Product(int.Parse(item.id_Product.ToString()))" width="100"></a></td>
<td class="product"><a href='../Kala/Product?NID=@item.id_ Product ' title='@item.comment'>@item.name_ Product </a> </td>
<td class="stock">@item.number</td>
<td class="price"><s></s> <b>@item.cost </b></td>
<td class="price"><b>@(item.number*item.cost) </b></td>
</tr>
}
<tr>
</tr>
</tbody>
.
.
.
しかし、それは上記の Item1 を認識しません。