Click here to Skip to main content
15,885,887 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi to all,
Here i want to populate Country and Automatically Load State and load city .Kindly help me for this then im using mvc 5 Repository pattern.Where to write that code in repository or controller. Because im new for mvc.
Posted
Comments
Nathan Minier 28-Oct-14 7:09am    
I think you need to start with primers. Here's one resident on CodeProject:
http://www.codeproject.com/Articles/765519/ASP-NET-MVC-for-Beginners-in-Web-Development
JOTHI KUMAR Member 10918227 28-Oct-14 7:20am    
i know this all. give solution for above task

Anticipating that you know the code to be written, I am writing you the flow and steps to follow in Repository pattern.
First, Always try to add the context code i.e. the database operations in the Service or Repository whichever you have. Context operations should not be added to the Controller.

Repository Pattern is a must in MVC application as it provides loose coupling, that is great for maintainance. So, for this you need to use Dependency Injection

Now for the query you have mentioned, you first need to make an ajax call to get the list of countries, i.e. the Action method that would call the Repository where the GetCountryList(), suppose would be there. This returns a list of Countries.

Then populate these values in a dropdown and onSelect event for the dropdown, add a function that would make two ajax call for getting the list of State, similarly on select of the State follow the same function on select event for the dropdown.

Please follow up, if any queries post back.
Thanks. :)
 
Share this answer
 
Comments
JOTHI KUMAR Member 10918227 28-Oct-14 7:39am    
yeah understand but given some sample code for above task
[no name] 28-Oct-14 7:53am    
look into Nels Solutions. That would be appropriate for you.
Thanks
:)
 
Share this answer
 
v2
Comments
JOTHI KUMAR Member 10918227 28-Oct-14 8:38am    
i need code can anyone help me
King Fisher 28-Oct-14 8:49am    
we are not Proving Any code here,we can guide you,but we can't write code for you. keep looking :)
JOTHI KUMAR Member 10918227 28-Oct-14 8:55am    
yeah i know but im fresher just guide as simple
King Fisher 28-Oct-14 9:01am    
Updated .download and try it .Good Luck :)
JOTHI KUMAR Member 10918227 29-Oct-14 5:32am    
where to download

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900