我希望在第一篇文章中传递一个id作为参数,在我的控制器的第二篇文章中将模型作为参数传递。任何人都可以说如何实现这一点。 [英] I want pass an id as parameter in the first post and the model as parameter in the second post in my controller.Can anyone say how to achieve this.

查看:109
本文介绍了我希望在第一篇文章中传递一个id作为参数,在我的控制器的第二篇文章中将模型作为参数传递。任何人都可以说如何实现这一点。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继承我的代码...



public ActionResult Create(int ReceiptId,PaymentPaidViewModel.detail details)

{

PaymentPaidViewModel.detail details = new PaymentPaidViewModel.detail();



if(details.idSelected == false)

{

var result = PaymentPaidViewModel.TotaltobePaid(ReceiptId);

return查看(结果);

}



else if(details.idSelected == true)

{-----}







这不起作用,我认为因为当我做第一篇文章时,只发送了ReceId

Heres my code...

public ActionResult Create(int ReceiptId,PaymentPaidViewModel.detail details)
{
PaymentPaidViewModel.detail details = new PaymentPaidViewModel.detail();

if (details.idSelected == false)
{
var result = PaymentPaidViewModel.TotaltobePaid(ReceiptId);
return View(result);
}

else if (details.idSelected == true)
{ ----- }



this is not working, i think because when i do the first post only the receiptId is sent

推荐答案

试试这段代码。



Try this code.

public ActionResult Create(int ReceiptId,PaymentPaidViewModel.detail details)
 {
                if(details != null)
                { 
                    if (details.idSelected == false)
                    {
                        var result = PaymentPaidViewModel.TotaltobePaid(ReceiptId);
                        return View(result);
                    }
 
                    else if (details.idSelected == true)
                    { ----- }
                }
                else
                {
                        return View(ReceiptId);
                }
}


这篇关于我希望在第一篇文章中传递一个id作为参数,在我的控制器的第二篇文章中将模型作为参数传递。任何人都可以说如何实现这一点。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆