Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:26:21+00:00 2026-06-02T00:26:21+00:00

I have created a web application in mvc3 and created two partial views one

  • 0

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

        }

How can i show webgrid and populate dropdown with same Index()??

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:26:22+00:00Added an answer on June 2, 2026 at 12:26 am

    You are passing a SecurityIdentifierMapping model to the Index view. Inside this Index view you are calling 2 partials:

    @Html.Partial("_ControlsPartial")
    

    and:

    @Html.Partial("_WebGridPartial")
    

    The first one works fine because it is strongly typed to SecurityIdentifierMapping but the second one (the one with the grid) doesn’t work because it is strongly typed to IEnumerable<SecurityIdentifierMapping>. Thus the exception you are getting.

    I would recommend you using a view model which will contain 2 properties: one simple SecurityIdentifierMapping that you could pass to the first partial and an IEnumerable<SecurityIdentifierMapping> property that you will pass to the second partial. It is the controller action that will fill this view model and pass it to the Index view:

    Index.cshtml:

    @model MyViewModel
    
    <div>
        @Html.Partial("_ControlsPartial", Model.SecurityIdentifier)
    </div>
    
    <div>
        @Html.Partial("_WebGridPartial", Model.Identifiers)
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a web application in mvc3 and created two partial views one
i have created an mvc3 web application that uses forms based authentication. one part
I have created an MVC3 application and added cutomerrors attribute on in web.config. It
I have created a web application using ASP.NET MVC3 in Visual studio (no SQL
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have created a Web Application in asp.net 2.0. which is working fine on
We have created a web application, using ASP.NET, that allows users to upload documents
I have created a web application using Visualstudio 2008 using C# on my computer.
I have created a web application with a Silverlight project embedded in it, using
I have created a site collection inside a web application with user A as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.