Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
jquery to bind states in dropdown when country is selected from another dropdown in MVC 4 while registering user..

I have got the states name in one list "stateList" while selecting country name from dropdown through the function "GetStatesList"

[HttpPost]
[AllowAnonymous]
public ActionResult GetStatesList(int countryid)
{
TracFindDALContainer tracFindStates = null;
List<registermodel> stateList = null;
try
{
using (tracFindStates = new TracFindDALContainer())
{
var statebind = (from s in tracFindStates.States
join c in tracFindStates.Countries on s.Id equals c.Id
where s.CountryID == countryid
select new RegisterModel
{
Stateid =s.Id,
StateName =s.StateName });

if (statebind == null)
return Json(null);
stateList = (List<registermodel>)statebind.ToList();
return Json(stateList);

}
}
catch (Exception ex)
{
LogManager.WriteErrorLog(ex);
objStringBuilder.Clear();
objStringBuilder.AppendLine("Start: StateList, StateList Method");
objStringBuilder.Append(ex.Message);
LogManager.WriteTraceLog(objStringBuilder);
return null;
}

}

but thruogh jquery I am not getting states in doropdown..

Plz help...
Posted
Updated 12-Sep-13 3:35am
v2

1 solution

 
Share this answer
 
Comments
akrati shakya 5-Sep-13 9:49am    
Actually i want the solution containing view , controller and should have function ...
Jameel VM 5-Sep-13 10:31am    
i recommend you to use ajax call.

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