[英]MVC how can i create (10)multiple textbox and have one parameter assign to those text box. I also want to pass the parameter to my controller
public ActionResult Orders1(int order)
{
CostcoEntities1 context = new CostcoEntities1();
var query = from a in context.CM_Checkout_Details
where a.CheckoutDetails_ID == order
select a;
return View(query);
}
大家好!! 我是新手,需要一些帮助。 我想创建10个文本框以显示参考项详细信息。 第一个文本框可以正常工作,但是第二个文本框指出order参数为null。 我知道这是一个简单的任务,而且我对MVC还是很陌生。 请帮助!!我更喜欢使用html helper(如果可能的话)
先感谢您!!!
视图
@using (Html.BeginForm("Orders1", "Track", FormMethod.Post))
{
for (int i = 1; i < 11; i++)
{
@i <input type="text" name="order" /><br />
}
<input type="submit" value="Submit" />
}
我相信这将是您想要的。 您可以根据需要扩展htmlAttributes。
@model IEnumerable<TypeGoesHere>
@foreach(var item in (IEnumerable<TypeGoesHere>)Model)
{
@Html.TextBoxFor(x=>item.SomeProperty, null,new {@name="order"})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.