title: MVC 4 Razor - Creating a dynamic DropDownList
body: <p>I'm trying to create a view which has two DropDownLists. The options available in the second DropDownList depend upon what the user has selected in the first. I'm passing this data to my view in the ViewBag as follows:</p>
  
  <pre><code>   List&lt;SelectListItem&gt; firstBoxChoices =  ViewBag.firstBoxChoices;
     Dictionary&lt;string, List&lt;SelectListItem&gt;&gt; secondBoxDict = ViewBag.secondBoxDict;
  </code></pre>
  
  <p>The first object has the choices for the first DropDownList. When the user selects one of those, I need to get the appropriate list of choices for the second DropDownList from my Dictionary. I just can't figure out how to achieve this. If I get the new selection of the first DropDownList in a Javascript onchange() function, there doesn't seem to be any way to use this value as the key for my C# dictionary. </p>
  
  <p>Of course, I've seen this functionality on the web so I know it must be possible somehow. How can I achieve this?</p>
  
  <p>Thanks!</p>