0
내가 잘못하고있는 것을 알고 있지만 LINQ 측면에서이를 수정하는 방법을 알지 못한다. 보시다시피, 내 데이터를 목록으로 쿼리하고 있지만 내 모델에서 "ProfileModelData"를 기대하고 있습니다. 모든 것을 정렬하도록 어떻게 수정합니까?부분 뷰 모델에 잘못된 데이터 유형 전달. 수정하려면 어떻게해야합니까?
컨트롤러 :
public ActionResult _ProfilePartial(string Id)
{
ProfileModel model = new ProfileModel();
string un = Id;
model.pdata = (from p in db.Users
where p.userid == un
select new ProfileModelData { lastname = p.lastname }
).ToList();
return PartialView("_ProfilePartial", model.pdata);
}
부분보기 :
@model MyApp.Models.ProfileModelData
<form id="EnrollForm" action="/MyView/SaveProfile" method="post" enctype="multipart/form-data">
<table>
<tr>
<td colspan="2">
<h3>Required Information</h3>
</td>
</tr>
<tr>
<td>E-Mail Address*</td>
<td>
<span class="NoWrap">
<input class="JobApplyInput FormReq" name="form_email1" id="form_email1" value="@Model.lastname" />
<label id="Req_Join_Email" for="form_email1">
@Html.Partial("_RequiredFieldPartial")
</label>
</span>
</td>
모델 클래스 :
public class ProfileModelData
{
public string lastname { get; set; }
}
public class ProfileModel
{
public List<ProfileModelData> pdata { get; set; }
}
는 "LASTNAME" "이메일"입력에 가고 있다는 사실을 무시하십시오. 나는 지금 당장 개념대로 작업하려고 노력 중이다. u는 뷰 모델로`ProfileModel`을 받아이 arent 이유
을, 목록을
First
를 사용하고 반환? –