0

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 });
        }
2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by elsunhoty
0
carList = carService.GetCarsByCompanyId(Convert.ToInt32(selectedValue)).OrderByDescending(u=>u.Id);

Edited by elsunhoty

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.