如何将值从视图传递给控制器。 [英] how to pass value from view to controller.
本文介绍了如何将值从视图传递给控制器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Asp.net mvc4将数据(值)从视图传递到@ html.actionlink中的控制器。
How to pass a data(value) from view to controller in @html.actionlink using Asp.net mvc4.
推荐答案
您可以使用以下systax
查看看起来像
You can use following systax
View looks lik
@Html.ActionLink("Edit", "Edit", "StudentManager",new { id = item.StudentID }, null)
其中StudentManager是控制器名称,Edit是Action,id是我的参数通过查询字符串
我的控制器就像是
where "StudentManager" is controller name, "Edit" is Action, "id" is the parameter which i pass through querystring
MY controller is like
public ActionResult Edit(int id)
{
//Your code
return View(student);
}
这篇关于如何将值从视图传递给控制器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文