Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I got the error '
The model item passed into the dictionary is of type 'DevExpress.DashboardWeb.WorkingMode', but this dictionary requires a model item of type 
' on rendering partial view in popup on button click.

Here I have taken three partial views in index.cshtml view page.

Three partial views have different models.

In the popup content i am calling partial view of another form.

I have created tuple in which i defined two models but still got the same error.

Please suggest me.

What I have tried:

index.cshtml

@model Tuple<DevExpress.DashboardWeb.WorkingMode, DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data>


 @Html.Partial("~/Views/Home/DashboardPartial.cshtml")
@*</div>*@
@*<div style="position: absolute; left:0px;top:40px;right:350px;bottom:0;
height: 100%;
          ">*@
@(Html.DevExpress().PopupControl(settings =>
           {
               settings.Name = "PopupControlSelectSub";
               settings.ShowOnPageLoad = false;
               settings.ShowMaximizeButton = true;
               settings.Width = 1200;
               settings.Height = 900;
               settings.CallbackRouteValues = new { Controller = "Home", Action = "Main_Menu" };
               settings.AllowDragging = true;
               settings.CloseAction = CloseAction.CloseButton;
               settings.PopupAnimationType = AnimationType.Slide;
               settings.HeaderText = "Main Menu";
               settings.Modal = true;
               settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
               settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
               settings.PopupElementID = "btnName_CD";
               settings.ScrollBars = ScrollBars.Horizontal;
               settings.SetContent(() =>
               {
                   Html.RenderPartial("Main_Menu");
               });
           }).GetHtml())
@Html.Partial("~/Views/TreeView/VirtualModePartial.cshtml")
@Html.Partial("~/Views/Home/ForecastGridPartial.cshtml")


Main_Menu.cshtml

C#
@model DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data
<link href="~/Content/ForbiddenZones.css" rel="stylesheet" />
<script src="@Url.Content("~/Content/scripts.js")" type="text/javascript"></script>
@{
    ViewBag.Title = "Main Menu";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Main Menu</h2>
@Html.DevExpress().DockPanel(
        settings =>
        {
            settings.Name = "panel1";
            settings.PanelUID = "panel1";
            settings.HeaderText = "Requester's Perimeter";
            settings.VisibleIndex = 0;
            settings.Width = 200;
            settings.Height = 200;
            settings.ShowHeader = true;
            settings.ShowCloseButton = false;
            settings.AllowResize = true;
            settings.OwnerZoneUID = "leftZone";
            settings.Styles.Content.Border.BorderStyle = BorderStyle.Solid;
            settings.Styles.Content.Border.BorderWidth = 1;
            settings.Styles.Content.Border.BorderColor = Color.FromArgb(0xBBD7E7);
            settings.Styles.Content.BackColor = Color.FromArgb(0xDBEBF4);
            settings.Styles.Content.Paddings.Padding = 0;
            settings.SetContent(() =>
            {
                @Html.DevExpress().Label(
                    s =>
                    {
                        s.Name = "Label1";
                        s.Text = "Req Section:";
                    }
                    ).GetHtml();
                @Html.DevExpress().ComboBox(
                    q =>
                    {
                        q.Name = "ddl_Req_Section";
                        //q.Properties.DataSource = AINIPMKPIDashboard.Models.MainMenu.GetRequiredSelection();
                        //q.CallbackRouteValues = new { Controller = "Home", Action = "Main_Menu", id = localvar };
                        q.Properties.ValueField = "txt_Req_Section";
                        q.Properties.TextField = "txt_Req_Section";
                        q.Properties.ValueType = typeof(string);
                        q.Properties.NullText = "All";
                        q.Properties.DropDownStyle = DropDownStyle.DropDown;
                        
                    }
                    ).BindList(ViewBag.GetReqsellist).Bind(Model.txt_Req_Section).GetHtml();
                @Html.DevExpress().Label(
                   a =>
                   {
                       a.Name = "Label2";
                       a.Text = "Req IPT:";
                   }
                   ).GetHtml();
                @Html.DevExpress().ComboBox(
                    b =>
                    {
                        b.Name = "ddl_Req_IPT";
                    }
                    ).GetHtml();
}
Posted
Updated 8-Aug-17 23:55pm

1 solution

Html.RenderPartial("Main_Menu");


You're not giving the partial view a model so (I think) it uses the model of the parent which is your Tuple, however Main_Menu needs vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data. Try something like

Html.RenderPartial("Main_Menu", Model.Item2);


that will pass the ...._Current_Data part of the parent model to the partial view as its own model.
 
Share this answer
 
Comments
TarunKumarSusarapu 9-Aug-17 5:59am    
I have already given but still getting the same error
F-ES Sitecore 9-Aug-17 6:02am    
It's hard to know the exact issue as the full error isn't posted, but it's fairly self-explanatory. You need to identify the view that is having the issue, identify what is calling that view, and make sure the view is given the correct model.
TarunKumarSusarapu 9-Aug-17 6:07am    
Here I am explaining in simple way

This is my main view rendering four partial views with different models that's why i created Tuple.

@*@model Tuple<DevExpress.DashboardWeb.WorkingMode, DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data>*@


@Html.Partial("~/Views/Home/DashboardPartial.cshtml")

@Html.Partial("~/Views/TreeView/VirtualModePartial.cshtml")

@Html.Partial("~/Views/Home/PopupPartial.cshtml")

@Html.Partial("~/Views/Home/ForecastGridPartial.cshtml")

For Popuppartial view in the content section i am calling another partial view which contains model as item2 in the tuple

PopupPartial.cshtml

@(Html.DevExpress().PopupControl(settings =>
{
settings.Name = "PopupControlSelectSub";
settings.ShowOnPageLoad = false;
settings.ShowMaximizeButton = true;
settings.Width = 1200;
settings.Height = 900;
settings.CallbackRouteValues = new { Controller = "Home", Action = "Main_Menu" };
settings.AllowDragging = true;
settings.CloseAction = CloseAction.CloseButton;
settings.PopupAnimationType = AnimationType.Slide;
settings.HeaderText = "Main Menu";
settings.Modal = true;
settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
settings.PopupElementID = "btnName_CD";
settings.ScrollBars = ScrollBars.Horizontal;
settings.SetContent(() =>
{
Html.RenderPartial("Main_Menu");
});
}).GetHtml())


On loading the page I got this error

The model item passed into the dictionary is of type 'devexpress.dashboardweb.workingmode', but this dictionary requires a model item of type '@model DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data'
F-ES Sitecore 9-Aug-17 6:16am    
That error makes it look like you haven't properly defined the "@model" in the partial view. The error should look like

The model item passed into the dictionary is of type 'devexpress.dashboardweb.workingmode', but this dictionary requires a model item of type 'DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data'

I still can't work out what views have what model and you still haven't said which model has the problem so it's hard to give any advice beyond making sure that you supply the right model to the right view. If you're nesting partial views you still need to do that, from your code you're not giving any partial views a specific model...it's not magic, it can't work out what it should use for a model, you have to give it the model.
TarunKumarSusarapu 9-Aug-17 6:21am    
Still got the error on assigning models to the partial view

@model Tuple<DevExpress.DashboardWeb.WorkingMode, DashboardDemo.Models.vw_100_QUERY_FOR_XLS_WEEK_IN_PROGRESS_016_Forecast_Follow_Current_Data>


@Html.Partial("~/Views/Home/DashboardPartial.cshtml",Model.Item1)

@Html.Partial("~/Views/TreeView/VirtualModePartial.cshtml")

@Html.Partial("~/Views/Home/PopupPartial.cshtml",Model.Item2)

@Html.Partial("~/Views/Home/ForecastGridPartial.cshtml",Model.Item2)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900