Passing a List<> to a view MVC

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

Hello,
I have this in my controller:
public ActionResult Index(Pick model)
{
model.GetTeams();
return View(model.Seed);
}

And I have this in My view:
<% = this.ViewData.Model.Seed[1]%>

and in my Model:
List<string> Seed = new List<string>();

Seed gets poulated from a db(this works) and the debugger shows the
data right up till the Page getting rendeered. My error is:
The model item passed into the dictionary is of type
'System.Collections.Generic.List`1[System.String]', but this
dictionary requires a model item of type 'NCAA.Models.Pick'.

What is the correct way of doing this?
Thanks
 
Hello,
I have this in my controller:
public ActionResult Index(Pick model)
        {
            model.GetTeams();
            return View(model.Seed);
        }

And I have this in My view:
 <% = this.ViewData.Model.Seed[1]%>

and in my Model:
List<string> Seed = new List<string>();

Seed gets poulated from a db(this works) and the debugger shows the
data right up till the Page getting rendeered. My error is:
The model item passed into the dictionary is of type
'System.Collections.Generic.List`1[System.String]', but this
dictionary requires a model item of type 'NCAA.Models.Pick'.

What is the correct way of doing this?
Thanks

I got it, I passed the entire model.
 
Back
Top