This is a migrated thread and some comments may be shown as answers.

[Solved] How Do I handle Null SelectList

0 Answers 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
william
Top achievements
Rank 1
william asked on 28 Feb 2012, 01:11 PM
Hi All,

I have my cascade combos and it calls the following:
[HttpPost]
        public JsonResult GetDropDownGroup(int? Dropdown_Group, int manufactureID)
        {
            //DropDown_Group contains the ID of the model selected. However, we need to obtain Advisory Groups for ALL models with the
            //selected description, so use the ID only as the initial entry
            try
            {
                return
                    Json(new SelectList(RoadRiskService.GetDropDownGroup(Dropdown_Group, manufactureID), "Id", "Value",
                                        JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return null;
            }
        }
If there happens to be nothing returned then it drops into my catch, however I receive the error invalid JSON. I have also tried return JSON(null); but this also fails.
Tags
ComboBox
Asked by
william
Top achievements
Rank 1
Share this question
or