开发者

Working with MVC3 @using to display a control

I have this piece of code in a .cshtml.

@using (Html.BeginRouteForm("CheckoutShippingAddress", FormMethod.Post))
{
 <div class="enter-address-body">
 @{
 var dataDictPatient = new ViewDataDictionary();
 dataDictPatient.ModelState.Merge(ViewData.ModelState);
 dataDictPatient.TemplateInfo.HtmlFieldPrefix = "PatientInformation";
  @Html.Partial("_CreateOrUpdateAddress", Model.PatientRoom, dataDictAddress)              
  }

what is happening is an error

The m开发者_C百科odel item passed into the dictionary is of type 'Models.Common.PatientModel', but this dictionary requires a model item of type 'Models.Common.AddressModel'.

what i don't understand is i changed the dictionary to want patientmodel and not addressmodel.


You need to make sure the PatientRoom property of your model is declared as a PatientModel (eg. you didn't just change the name to PatientRoom but leave the type as AddressModel, and also that the @model statement at the top of your _CreateOrUpdateAddress model is @model PatientModel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜