【问题标题】:MVC - two text box with the same parameterMVC - 两个具有相同参数的文本框
【发布时间】:2012-12-12 14:25:15
【问题描述】:
@using (Html.BeginForm("Orders1", "Track", FormMethod.Post))
{
         @Html.TextBox("order")<br />
         @Html.TextBox("order")
        <input type="submit" value="Submit" />
}

您好,我如何使用两个文本框并将值传递给同一个参数?第一个文本框工作,但另一个文本框没有。

   public ActionResult Orders1(IEnumerable<int> order)
        {
             var query = from   a in context.CM_Checkout_Details
                        where  a.CheckoutDetails_ID == order // my error
                        select a;


            return View(query);
        }

    }

【问题讨论】:

  • 我想显示 CheckoutDetails_ID 和订单的所有匹配 id

标签: asp.net-mvc


【解决方案1】:

简单的解决方案是将您的参数从 int 更改为 IEnumerable&lt;int&gt;

public ActionResult Orders1(IEnumerable<int> orders)
{

}

【讨论】:

  • 谢谢您的回复。我编辑我的控制器并在 where 子句行中出现错误......我如何转换我的 order 参数,因为它是 IEnumerable ???提前谢谢你
猜你喜欢
  • 2020-03-28
  • 2021-09-02
  • 2018-05-29
  • 2013-05-23
  • 1970-01-01
  • 2010-10-03
  • 2017-06-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多