Passing a List<> to a view MVC

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
 
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

I got it, I passed the entire model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top