English 中文(简体)
输入字典的模型项目类型需要一个类型系统的示范项目。 收集。 通用性。 ......
原标题:The model item passed into the dictionary is of type requires a model item of type System.Collections.Generic.IEnumerable`

I have created a web application in mvc3 and created two partial views one having controls like dropdownlist. second having webgrid which shows data from database.

partialview1.cshtml
@model Mapping.Models.SecurityIdentifierMapping

@using (Html.BeginForm("Mapping", "Home"))
{
    @Html.DropDownList("SecurityID", Model.PricingSecurityID, "-- Select SecurityID --")
    <br />    
    @Html.DropDownList("CUSIPID", Model.PricingSecurityID, "-- Select CUSIPID --")
    <br />
    <button type="submit">Map</button>
}

partialview2.cshtml
@model IEnumerable<Mapping.Models.SecurityIdentifierMapping>

@{
    ViewBag.Title = "Mapping";
    WebGrid grid = null;
    if (Model.Count() > 0 ){
    grid = new WebGrid(source: Model,
                            defaultSort: "Id",
                            canPage: true,
                            canSort: true,
                            rowsPerPage:20);
    }
}


<h2>Mapping</h2>


@if (grid != null)
{
@grid.GetHtml(
                tableStyle: "grid",
                headerStyle: "head",
                alternatingRowStyle: "alt",
                columns: grid.Columns(
                                            grid.Column("", header: null, format: @<text>@Html.ActionLink("Edit", "Edit", new { id = (int)item.id })  @Html.ActionLink("Delete", "Delete", new { id = (int)item.id })</text>),
                                            grid.Column("PricingSecurityID"),
                                            grid.Column("CUSIP")
                                          )

                )
}
<br />
<p>
    @Html.ActionLink("Back", "Index")
</p>

in index.cshtml


<div>
@Html.Partial("_ControlsPartial",)
</div>

<div>
@Html.Partial("_WebGridPartial")
</div>

HomeController.cs
  public ActionResult Index()
        {
            SecurityIdentifierMapping objModel = new SecurityIdentifierMapping();
            objModel.PricingSecurityID = objRepository.GetPricingSecurityID();
            objModel.CUSIP = objRepository.GetCUSIP();
            return View(objModel);

        }

如何用同样的指数显示网格和人口下降?

getting error :( what should be 2nd parameter inside @Html.Partial() so that both grid and control works fine on same page.?

最佳回答

页: 1 在该指数中,你称:

@Html.Partial("_ControlsPartial")

并且

@Html.Partial("_WebGridPartial")

第一个作品由于被严格分类为 安保证书/编码>,而第二个作品(有电网的)则从事t工作,因为它被严格分类为<代码>。 IE amountable< SecurityIdentifierMapping>。 因此,你正在获得例外。

我建议你采用一种观点模式,其中将包含2种特性:一种简单的<条码>,即你可以传递给第一部部分和<条码>。 IE amountable< SecurityIdentifierMapping> property that You will adopt to the second part. 管制者的行动将填补这一看法模式,并将其传达给索引:

www.un.org/spanish/ga/president

@model MyViewModel

<div>
    @Html.Partial("_ControlsPartial", Model.SecurityIdentifier)
</div>

<div>
    @Html.Partial("_WebGridPartial", Model.Identifiers)
</div>
问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签