Hi all, I'm having problem with building up cascading dropdown. I found tutorial on the net which were using 'Int' data. But my data to pass from database are of 'String'. How to change it?
Tutorial link: http://20fingers2brains.blogspot.sg/2013/04/cascading-dropdowns-in-aspnet-mvc3.html
I only requires help on certain area only. Please see code below which require changes for string..
[HttpPost]
//Gets the Cars based on the company selected in first Dropdown.
//Method accepts selectedValue as parameter. This is basically the selected value of first dropdown.
public ActionResult GetCarsBycompany(string selectedValue)
{
//Created object of service class which holds the method that queries database.
Car carService = new Car();
//Created a list of string to hold car names from Database.
List<string> carList = new List<string>();
//Populating the list by calling GetCarsByCompanyId method of service class.
carList = carService.GetCarsByCompanyId(Convert.ToInt32(selectedValue));
//Returning the list using jSon.
return Json(new { CarList = carList });
}