在一个view中(不妨设为category.cshtml),有companyid和productid两个参数要传回相应的product控制器的details方法中处理,即
public ActionResult Details()
{
   //根据传回来的companyid和productid查询数据库,并在detail.cshtml中显示。
}
问题是,我在这个action中如何获得category.cshtml中传回的companyid和productid参数呢?换句话问,就是在category.cshtml中用什么方法将这两个参数传给Details这个action?

解决方案 »

  1.   

    http://shashoutian2005.blog.163.com/blog/static/168541520100119595808/ 着急慢慢看,
      

  2.   

    楼上的,我也考虑用actionlink,但不知参数如何设置,例如@Html.ActionLink("linktext", "Details", "Product",new{companyid},null)
    是这样用吗?但似乎只能传回一个参数啊。
      

  3.   

    用提交表单的方式,可以带N个参数:
    使用@Html.BeginForm来提交表单另外@Url.RouteUrl()可以带很多参数:
    @Url.RouteUrl({action="", controller="", fId="", fName=""}),参数关键字随意指定。