It is possible to pass an empty list to DropDownList In your controller, you should have something like: var status_code_id = mymodel. Status_code_id; var substatus_code_id = mymodel. Substatus_code_id; ViewData"status_code_id" = new SelectList( StatusCodes.FindAll(), "id", "code", status_code_id); ViewData"substatus_code_id" = new SelectList( SubstatusCodes.
FindAllForStatus(status_code_id), "id", "code", substatus_code_id) where FindAllForStatus contains the same code you're using in your AJAX call to populate the substatus dropdownlist. FindAllForStatus should take in an empty status code and return an empty list In your view, you should have something like: %= Html. DropDownList("status_code_id", "--not selected--")%> DropDownList("substatus_code_id", "--not selected--")%.
It is possible to pass an empty list to DropDownList. In your controller, you should have something like: var status_code_id = mymodel. Status_code_id; var substatus_code_id = mymodel.
Substatus_code_id; ViewData"status_code_id" = new SelectList( StatusCodes.FindAll(), "id", "code", status_code_id); ViewData"substatus_code_id" = new SelectList( SubstatusCodes. FindAllForStatus(status_code_id), "id", "code", substatus_code_id); ...where FindAllForStatus contains the same code you're using in your AJAX call to populate the substatus dropdownlist. FindAllForStatus should take in an empty status code and return an empty list.In your view, you should have something like.
Return just 1 dummy item, let the javascript check for this item and then disable the second dropdownlist.
In my controller, I retrieve the list of possible status codes from the database and put the values in a SelectList that is used by the DropDownList HTMLHelper to build my select list in the view. I retrieve a model record that contains a status code and use that status code value to look up the possible values of substatus in the database, and I put that list in another SelectList for the second dropdown. The page makes an ajax call back to the server to repopulate the substatus dropdown with a new list of possible values when the user changes the selection in the status dropdown.
An empty status code really isn't a valid value, but this is a quality control app that is used to correct such problems. My problem is that the current status code on the model record can sometimes be empty and therefore my list of substatus values for the second dropdown will be empty. Unfortunately there seems to be no way to create an empty SelectList to pass to the DropDownList HTMLHelper, but my dropdown list must be created when the page loads to support my ajax solution.
Has anyone worked out an efficient and super slick way to handle such scenarios? Or do I need to resort to something ugly like checking in my view if the substatus SelectList is null, and if it is using different HTML to generate the dropdown? It seems in my sick mind that being able to generate an empty SelectList to hand off to the HTMLHelper would be a reasonable solution.
I'd welcome any ideas.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.