i have two controller customer and order in mvc Application ..I wnat to show customer in drop down list in order controller when click on order create ..or click on following url .http://localhost:1957/order/Create

any help ..

Recommended Answers

All 3 Replies

You need to get a collection of customers in your model. You do this in your controller and pass the model to your view. For example:

var model = new MyModel();

model.Customers = GetCustomers();

return View(model)

Then in your view you have something like:

@Html.DropDownListFor(model => model.CustomerId, new SelectList(Model.Customers, "Id", "Name"), "")

Member Avatar for diafol

Any chance of letting us know which language and which framework (if any) you're using?

can you share GetCustomers() function body ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.