C#,。Net 4
参考下面的XX1,XX2,XX3(在标题=>观点:主视图{最后特别是@ Html.ActionLink位}}:
对象在主控制器中初始化。 (具有子对象的detial(在Action Result中初始化)
我在XX1等处添加了断点,以确认初始值仍然存在。
为什么感兴趣的控制器等控制器没有接收传递给它的参数(_PersonCoi,而不是idx)。
型号:
public class CoiSPersonDetail
{
public PersonDetail MyDetail { get; set; }
public ConflictOfInterestPerson PersonSummary { get; set; }
}
public class ConflictOfInterestPerson
{
public int Number { get; set; }
public PersonDetail PersonDetailItem;
public List<ConflictOfInterestItem> ConflictOfInterestList;
public List<FinancialInterestItem> FinancialInterestList;
public List<GiftInterestItem> GiftInterestList;
}
public class PersonDetail
{
public int Number { get; set; }
public string UserName { get; set; }
public string Name { get; set; }
public string Fullname { get; set; }
public string Surname { get; set; }
public Int64 ID { get; set; }
public string Designation { get; set; }
public int PeopleType { get; set; }
public string PeopleLine { get; set; }
public string PCUser { get; set; }
public string PCUserManagement { get; set; }
public string PCSearch { get; set; }
public IEnumerable<SelectListItem> PersonDetailList { get; set; }
public HttpPostedFileBase FileNameCOI { get; set; }
public HttpPostedFileBase FileNameFin { get; set; }
public HttpPostedFileBase FileNameGft { get; set; }
}
public class ConflictOfInterestItem
{
public string Header { get; set; }
public int ConflictID { get; set; }
public int DeclarationID { get; set; }
public int SectionID { get; set; }
public int QuestionareID { get; set; }
public string Question { get; set; }
public bool SupportDocument { get; set; }
public HttpPostedFileBase Document { get; set; }
public bool Explain { get; set; }
public bool YesNo { get; set; }
public string Reason { get; set; }
public Guid coiID { get; set; }
}
public class FinancialInterestItem
{
[DisplayName("Name of Organisation")]
public string Organization { get; set; }
[DisplayName("Nature Of Interest")]
public string NatureOfInterest { get; set; }
[DisplayName("Date Of Acquisition")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DateOfAcquisition { get; set; }
}
public class GiftInterestItem
{
[DisplayName("Supplier of Gift")]
public string Supplier { get; set; }
[DisplayName("Recipient of Gift")]
public string Recipient { get; set; }
[DisplayName("Type of gift / entertainment")]
public string Type { get; set; }
[DisplayName("Estimated value")]
public float EstimatedValue { get; set; }
[DisplayName("Date received")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DateReceived { get; set; }
[DisplayName("Ultimate use")]
public string UltimateUse { get; set; }
}
控制器:
适用于主视图
public ActionResult Index(string Number, string Search, string Fullname, string Surname, string ID)
{
PersonDetail _MeCoI = new PersonDetail();
ConflictOfInterestPerson _PersonCoI = new ConflictOfInterestPerson();
_PersonCoI.PersonDetailItem = _db.ConflictOfInterestPerson(Number);
_PersonCoI.Number = _PersonCoI.PersonDetailItem.Number;
_PersonCoI.ConflictOfInterestList = _db.ConflictOfInterestList(_PersonCoI.Number.ToString());
_PersonCoI.FinancialInterestList = _db.ConflictOfFinancialInterestList(_PersonCoI.Number.ToString(), _PersonCoI.ConflictOfInterestList.First().coiID);
_PersonCoI.GiftInterestList = _db.ConflictOfGiftInterestList(_PersonCoI.Number.ToString(), _PersonCoI.ConflictOfInterestList.First().coiID);
CoiSPersonDetail CoiSpd = new CoiSPersonDetail();
CoiSpd.MyDetail = _MeCoI;
CoiSpd.PersonSummary = _PersonCoI;
}
其他观点:
感兴趣(控制人):
public ActionResult Form(ConflictOfInterestPerson _PersonCoI, string Idx)
{
//processing...
}
查看:
**主视图**
@model ConflictOfInterest.Models.CoiSPersonDetail
@{
ViewBag.Title = "OverView";
}
@using (Html.BeginForm("Index", "Home"))
{
@Html.AntiForgeryToken()
<h2>OverView</h2>
<p>
<!-- stuff -->
</p>
<strong>The Policy serves to provide guidance to all employees on:</strong>
<ul>
<li>what is a conflict of interest,</li>
<li>how to avoid conflict of interest</li>
<li>disclosing conflict of interest;</li>
<li>managing conflict of interest; and</li>
<li>disclosure of financial interest</li>
</ul>
<strong>What is a conflict of interest?</strong>
<ul>
<li><!-- stuff --></li>
<li><!-- stuff --></li>
<li><!-- stuff --></li>
<li><!-- stuff --></li>
</ul>
<strong>The following forms are available to assist:</strong>
<ul>
<li><a href="@ViewBag.PathtoPolicy" target="_blank">Policy Document</a></li>
<li>@Html.ActionLink("Conflict of Interest", "Form", "Home", new { _PersonCoI = Model.PersonSummary, idx = Model.PersonSummary.Number.ToString() }, null) </li> <!--XX1-->
<li>@Html.ActionLink("Declaration", "FRADecInt", new { _PersonCoI = Model.PersonSummary })</li> <!--XX2-->
<li>@Html.ActionLink("Gifts", "GiftDecInt", new { _PersonCoI = Model.PersonSummary })</li> <!--XX3-->
</ul>
}