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 8873315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:26:06+00:00 2026-06-14T18:26:06+00:00

I have a model for a view. This view contains a an @Html.DropDownList whose

  • 0

I have a model for a view. This view contains a an @Html.DropDownList whose values are in a model. How can I have my view take both model for different parts of the program?

For example, I have

@model IEnumerable<projectname.mymodel>
@{
   ViewBag.Title = "my title"
 }
 <!--This should use a different model-->
 <p>@Html.DropDownList(m =>m.name), new set(Model.list, "value", "key"))

If I have model1 and model2(connects to database)-all stored in the Model folder; and a big model class as something like

public class MyViewModel {
   public model1 var1 { get; set; }
   public IEnumerable<projectname.Model.model2> var2 { get; set; }
}

And i call this model in my view:

@model ProjectName.Models.Models

How do I reference an item in model1 or model2?

  • 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-14T18:26:07+00:00Added an answer on June 14, 2026 at 6:26 pm

    Just pass a new class as model to your view which contains all the data you need:

    public class MyViewModel {
        public SelectList list { get; set; }
        public IEnumerable<projectname.mymodel> Items { get; set; }
    }
    

    Another approach would be to pass the list in the Viewbag:

    Viewbag.list = new SelectList() ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have this code in my view.. <%=Html.DropDownList(ProductTemplate,new SelectList(Model.ProductTemplate,Value,Text))%> I know if this
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids
I have some problems with ASP.NET MVC’s default model binder. The View contains HTML
i have the following view that contains an @Html.DropDownList :- <fieldset> <legend>Answer here</legend> <div
I have a view that contains two @Html.DropDownListFor helpers: <div class=editor-field> @Html.DropDownListFor(model => model.Employee,
So I have this on my view: <%= Html.Encode(Model.STPData.ProjectName)%> Now say instead of having
I have a DropDownList that contains the correct items and values when the view
I have a view model that looks like this public class ViewModelRound2 { public
I have a view model coming from the server as json like this {
I have this attribute in my view model: [CustomRequired, EmailRegex] [Display(Name = KeepInformedPersonMail, ResourceType

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.