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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:25:30+00:00 2026-06-07T15:25:30+00:00

I have two model class in MVC3 one for Services which have those properties

  • 0

I have two model class in MVC3 one for Services which have those properties

public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public int ChildOf { get; set; }

It also have a DB table by Entityframework

Another model is Quata which have those properties

public int ID { get; set; }
public string Sender_Name { get; set; }
public string Description { get; set; }
.....
......
public Services Service_ID { get; set; }

It also have a DB table by Entityframework

I want to create a Razor(C#) view (for Quata) where user can send a quata by fill a html form but where i wanna show a dropdown list with Services ID as dropdown value and Services Name as dropdown text which is also come dynamically from the Services DB table .

My question is how i should create that dynamic dropdown list by @Html.DropDownListFor ? and send the selected data from that dropdown list to a Controller ?

  • 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-07T15:25:32+00:00Added an answer on June 7, 2026 at 3:25 pm

    Try this

    Controller:

     public ActionResult Create()
        {
            var Services = new Services();
    
            Services.Load(); //load services..
    
            ViewBag.ID = new SelectList(Services.ToList(), "Id", "Name");
    
    
            return View();
        }
    
    [HttpPost]
    public ActionResult Create(Quata Quata)
        {
            //save the data 
        }
    

    A strong Typed View: (Using Razor)

    @model Quata
    
    @using (Html.BeginForm()) {
    <fieldset>
        <legend>Quata</legend>
    
        <div>
            @Html.LabelFor(model => model.Service_ID.ID, "Service")
        </div>
        <div>
            @Html.DropDownList("ID", String.Empty)
        </div>
    
    
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes (MVC view model) which inherits from one abstract base class.
I have two models related one-to-many: a Post and a Comment : class Post(models.Model):
I have a fairly simple model: public class Delivery { public int DeliveryId {
My model is something like this: public class Line { public int CatalogNumber {get;
I have two models: class Customer(models.Model): (...) class CustomerMemo(models.Model): (...) customer = models.ForeignKey(Customer) text
I have two objects of the same class (Model) type. I want to check
I have two models: class Contact(models.Model): name = models.CharField(max_length=255) class Campaign(models.Model): contact = models.ForeignKey(Contact,
I have two models: class Actor(models.Model): name = models.CharField(max_length=30, unique = True) event =
I have two models like this: class ClassA(models.Model): ida = models.AutoField(primary_key=True) classb = models.ForeignKey(ClassB)
I have two models like this: class OptionsAndFeatures(models.Model): options = models.TextField(blank=True, null=True) entertainment =

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.