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

  • SEARCH
  • Home
  • 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 7785063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:11:44+00:00 2026-06-01T20:11:44+00:00

In my mvc3 application i’m getting this error on index() where properties are of

  • 0

In my mvc3 application i’m getting this error on index()
where properties are of type Nullable<int> and i cant change them to List<SelectListItem>
that is what my method return type because properties are auto generated by EF in this case what to do please help?

INDEX.CSHTML
@model Mapping.Models.SecurityIdentifierMappingViewModel

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


@*Partial control for all controls*@

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


<div>
@Html.Partial("_WebGridPartial",Model.MappingWebGridList)
</div>
public ActionResult Index()
    {

        var mappingobj = new SecurityIdentifierMappingViewModel();

        mappingobj.PricingSecurityID = objRepository.GetPricingSecurityID();
        mappingobj.CUSIP = objRepository.GetCUSIP();

        var viewModel = new SecurityIdentifierMappingViewModel
        {
            MappingControls = mappingobj.MappingControls,
            MappingWebGridList = dbContext.SecurityIdentifierMappings.ToList()
        };

        return View(viewModel);


    }

controlpartial.html
@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>
}

webgridpartial.cshtml
     @model IEnumerable<Mapping.Models.SecurityIdentifierMappingViewModel>

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

securityidentifiermapping.cs //auto generated by EF
 public partial class SecurityIdentifierMapping
    {
        public int Id { get; set; }
        public Nullable<int> PricingSecurityID { get; set; }
        public string Calculation { get; set; }
    }

public List<SelectListItem> GetPricingSecurityID()
        {
        var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing.AsEnumerable()
                                     select new SelectListItem
                                         {
                                                Text = m.PricingSecurityID.ToString(),
                                                Value = m.PricingSecurityID.ToString()
                                         }).AsEnumerable();

        return pricingSecurityID.ToList();
        }

 public class SecurityIdentifierMappingViewModel
    {
        public IEnumerable<SecurityIdentifierMapping> MappingWebGridList { get; set; }
        public SecurityIdentifierMapping MappingControls { get; set; }

        public List<SelectListItem> PricingSecurityID { get; set; }
        public List<SelectListItem> CUSIP { get; set; }
    }

taken List<SelectListItem> because want to populate dropdownlist.
So in this case what should I do?

  • 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-01T20:11:45+00:00Added an answer on June 1, 2026 at 8:11 pm

    You have to create new property in ViewModel and set the List<SelectListItem> to that property

    public class SecurityIdentifierMappingViewModel
    {
        public List<SelectListItem> PricingSecurityList{get;set;}
    
    ...
    ...
    ...
    }
    

    public ActionResult Index(){
    .....
    ...
    ..
                var viewModel = new SecurityIdentifierMappingViewModel
                {
                    MappingControls = mappingobj,
                    MappingWebGridList = dbContext.SecurityIdentifierMappings.ToList(),
                    PricingSecurityList = objRepository.GetPricingSecurityID();
    
                };
    ...
    .....
    
    }
    

    View

    @Html.DropDownListFor(model=>model.MappingControl.PricingSecurityID, Model.PricingSecurityList)
    

    or

    @Html.DropDownList("SecurityID", Model.PricingSecurityList, "-- Select SecurityID --")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

inside mvc3 application i'm populating dropdownlist from database using following query. getting error on
I have an MVC3 application into which I'm integrating WIF. Before starting on this
I have an MVC3 application which has a reference to DLL. This DLL is
I'm following along the ASP.Net MVC3 application Music Store and I've noticed this. Here
I am working on asp.net mvc3 application. In this user can post data, i
net mvc3 application I have a checkbox: <input type=checkbox id=daStores name=CheckBox1 onclick=filter() /> How
In my MVC3 application I have the model ( not important properties deleted ):
In an MVC3 application, is it considered bad practice to use a try catch
I am developing an MVC3 application in C#. The application has several projects. Since
In an MVC3 application I have a view rendering two Ajax partial views: a

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.