Click here to Skip to main content
15,915,501 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Friend ,
I Want To Perform A Country Dropdown Select and State Dropdown Bind in mvc
Posted
Comments
Nelek 19-May-14 10:10am    
Perfect, go ahead and have fun coding.

Since you didn't ask any question, it is difficult to give you a better answer.

I strongly recommend you to read:
How to ask a question[^] and What have you tried?[^]

You have to handle the 'change' event of the select element in jQuery and do the stuff you want through ajax calls basically.

JavaScript
$('#ddlCountry').change(function() {
   // do the stuff operation to bind states as shown below
});


Use jQuery method .ajax() to populate the state dropdown here. Hope the below cod eexample will definitely of help for you :-

Ex

C#
$.ajax({
        type: "POST",
        url: "../WebService.asmx/GetAllStates",
        data: "{CountryID:'" + $('#ddlCountry').val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function (response) {
            $.each(JSON.parse(response.d), function (key, value) {
                $("#ddlState").append("<option value='" + value.StateID + "'>" + value.StateName + "</option>");
            });
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(failMessage);
        }
    });
 
Share this answer
 
Step 1) Do a little research. Google is a good start point
Step 2) Start coding
Step 3) Compile and use the debug to solve little issues
Step 4) When you get a problem you don't know how to solve but at least you tried it, then come back and ask for something concrete with a snippet of the code giving problems

Sorry if this is not the answer you were looking for. But your question is a bit too wide to be answered at the "Quick" Answers. It is better and you get faster help if you make 10 concrete questions about concrete problems, than a big question about a "how-to guide"

P.S. Written as solution to avoid this "question" to be in the unanswered list
 
Share this answer
 

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