gpt4 book ai didi

c# - 从 Controller 传递时数据不显示

转载 作者:太空宇宙 更新时间:2023-11-03 21:01:41 25 4
gpt4 key购买 nike

在 asp.net MVC 中获取模型值但在传递给 View 时未显示任何内容。

Controller

  public ActionResult Index(plan plan1)
{
var myCharge = new StripeChargeCreateOptions();

string apiKey = "";
var stripeClient = new StripeClient(apiKey);
var planService = new StripePlanService(apiKey);
StripePlan response = planService.Get("1234");
plan1.Amount = (response.Amount).ToString();

return View();
}

查看

<div>
@Html.TextBoxFor(m => m.Amount)

</div>

如何在文本框中显示金额值

最佳答案

希望您的 View 与 Model 类(实例是 plan1)强绑定(bind)。所以,你需要在你的返回声明中指定你的模型

return View(plan1);

关于c# - 从 Controller 传递时数据不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44905872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com