gpt4 book ai didi

javascript - 数据到达 Controller 但不查看

转载 作者:行者123 更新时间:2023-12-05 04:39:27 25 4
gpt4 key购买 nike

 public ActionResult Index()
{

GetEmployee();

return View();
}

private void GetEmployee()
{

SocialMedia item = new SocialMedia();
var employee = _employeeRepository.GetById(Session.GetEmployeeNo());
//employee.No, employee.ManagerNo
item.FirstName = employee.FirstName;
item.LastName = employee.LastName;
item.Departmen = employee.PositionCode;
item.FullName = item.FirstName + " " + item.LastName;

}

还有我的 HTML

@using Models.Model

@model Models.Model.SocialMedia
<div>
@Html.LabelFor(model => model.FullName)
</div>
<div>
@Html.LabelFor(model=>model.Departmen)
</div>

我的结果是

全名部门

名字、姓氏和部门应该来但没有来。你能帮帮我吗

最佳答案

我本以为会是这样的:

public ActionResult Index()
{

var model = GetSocialMedia();

return View(model);
}

private SocialMedia GetSocialMedia()
{

SocialMedia item = new SocialMedia();
var employee = _employeeRepository.GetById(Session.GetEmployeeNo());
//employee.No, employee.ManagerNo
item.FirstName = employee.FirstName;
item.LastName = employee.LastName;
item.Departmen = employee.PositionCode;
item.FullName = item.FirstName + " " + item.LastName;
return item;
}

C#程序中的数据不会仅仅因为它是在A处创建的而出现在B处;它肯定会被传递,所以它最终会出现在预期的位置

关于javascript - 数据到达 Controller 但不查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70445783/

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