Tuesday, 17 September 2013

Passing dictionary to a View

Passing dictionary to a View

I am passing this type into my view
Dictionary<String, List<myObj>> results = ...
View(results);
My view has this declaration
<%@ Page Title="" Language="C#"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<IEnumerable<Models.myObj>>" %>
I run into this error: The model item passed into the dictionary is of
type
'System.Collections.Generic.Dictionary2[System.String,System.Collections.Generic.List1[Models.myObj]]',
but this dictionary requires a model item of type
'System.Collections.Generic.IEnumerable1[Models.myObj]'.`
This is because of the new structure I am sending down to the view. How do
I auto update the view so it uses the new param type?

No comments:

Post a Comment