when user come to Enter adddress but there Country,State etc does not in selction option.i want to add other option where user type manualy there address in cascading dropdown list sam as for State,city and store all values in DB. using Asp.net MVC
Loading

Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 19, 2024, 7:47 AM EDT
Hi,
You can implement cascading dropdown lists along with manual entry options in your ASP.NET MVC application. You can use JavaScript/jQuery for the cascading dropdown behavior and handle manual entry through text inputs.
Here's a high-level overview of the steps involved:
// Controller Action to fetch States based on selected Country public JsonResult GetStates(int countryId) { var states = db.States.Where(s => s.CountryId == countryId).ToList(); return Json(states, JsonRequestBehavior.AllowGet); } // View code for cascading dropdown lists @Html.DropDownListFor(model => model.CountryId, ViewBag.Countries as SelectList, "Select Country", new { id = "countryDropdown" }) @Html.DropDownListFor(model => model.StateId, new SelectList(Enumerable.Empty(), "Value", "Text"), "Select State", new { id = "stateDropdown" }) @Html.DropDownListFor(model => model.CityId, new SelectList(Enumerable.Empty(), "Value", "Text"), "Select City", new { id = "cityDropdown" })