0

Assuming i got a table called Countries and using Entity Framework, i want to know how could i populate the available countries (listed in the table countries) to view as drop down list and return the value to HTTPPost Controller

i got

public ActionResult SignUp() 
i think the populate code should be here but i not sure 
how to retrieve from entity framework and populate into view

and

 [httpPost]
 public ActionResult SignUp()
 i want to read the user selected value and i think is 
 int value = form["DropDownListName"].SelectedIndex + 1;

can anyone please guide me on this with some hint or example , please ? Thx a lot =D

1 Answer 1

2

To be honest, you're not really working in an MVC pattern here. Don't put UI construction logic in your constructor.

Rather, expose the ID that you want to bind to the list via a model that you pass to a View() method in your constructor.

In your view, use the name of that property as the Name of a Drop-down and create a helper class to generate the list of values.

I'd give you a more specific example, but I'm in the cinema with my iPad, so a bit stuck for access to Visual Studio at the moment!

Sign up to request clarification or add additional context in comments.

1 Comment

Can you please explain with some example ? i can't get you >.<

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.