[英]C# ASP.NET MVC ERROR IN RETURNING VALUES IN VIEW
I am working on an ASP.NET MVC project and I want to return to the view GuardarRegistro
three controller values, these values are IdSucursal
, IdProducto
, Cantidad
, but I get an error saying that我正在研究 ASP.NET MVC 项目,我想返回
GuardarRegistro
视图中的三个 controller 值,这些值是IdSucursal
、 IdProducto
、 Cantidad
,但我收到一条错误消息
CS1501 C # No overload for method 'View' takes 4 arguments
This is the code of the controller where the error appears这是出现错误的controller的代码
public ActionResult Nuevo(decimal IdSucursal = 0, decimal IdProducto = 0, decimal Cantidad = 0)
{
new RegistroAlmacenAdmin().GuardarRegistro(IdSucursal, IdProducto, Cantidad);
ViewBag.mensaje = "registro de almacen guardado";
return View("GuardarRegistro", IdSucursal, IdProducto, Cantidad);//CS1501 error in this line in word view
}
I was planning to create a new object inside the ActionResult
but I don't know how to do it right我计划在
ActionResult
中创建一个新的 object 但我不知道如何正确执行
Goodnight Thank you very much for the comments and the articles that helped me find an answer, I understand better oop, the answer code is as follows晚安 非常感谢评论和帮助我找到答案的文章,我比较了解oop,答案代码如下
model model
public partial class RegistroAlmacen
{
public decimal IdRegistro { get; set; }
public decimal IdSucursal { get; set; }
public decimal IdProducto { get; set; }
public decimal Cantidad { get; set; }
public virtual Producto Producto { get; set; }
public virtual Sucursal Sucursal { get; set; }
}
controller controller
public ActionResult Nuevo(decimal IdSucursal=0, decimal IdProducto=0, decimal Cantidad=0)
{
RegistroAlmacen objeto = new RegistroAlmacen
{
IdSucursal=IdSucursal,
IdProducto = IdProducto,
Cantidad=Cantidad
};
new RegistroAlmacenAdmin().GuardarRegistro(IdSucursal, IdProducto, Cantidad);
ViewBag.mensaje = "registro de almacen guardado";
return View("GuardarRegistro", objeto);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.