本文介绍了需要专业MVC的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,我该如何将数据从MVC视图传递到控制器?
我的看法:
I have a question, that how can I pass data from MVC View to Controller?
My View:
@ Html.Label(付款方式")
@Html.Label("Payment Method")
@ Html.DropDownList("PaymentMethod")
@ Html.ValidationMessageFor(model => model.PaymentMethod)
@Html.DropDownList("PaymentMethod")
@Html.ValidationMessageFor(model => model.PaymentMethod)
(ViewData ["PaymentMethod"]的定义
(Definition of ViewData["PaymentMethod"]
var paymentMethod = from p in db.PaymentMethods select p;
ViewData["PaymentMethod"] = new SelectList(paymentMethod,"ID","Name")
)
我想获取Dropdownlist ["PaymentMethod"]的值.但是如何?感谢您的帮助!
)
I wanna get the value of Dropdownlist["PaymentMethod"]. But how? Thanks for helps!
推荐答案
[HttpPost]
public ActionResult Index()
{
string paymentMethod = Request["PaymentMethod"];
}
这篇关于需要专业MVC的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!