0

誰かが次のことについてアドバイスしてくれるとありがたいです: 私はコントローラーの ActionResult を呼び出して文字列を渡し、データを取得します。このデータを使用して DropDownList に入力し、ユーザーに表示するにはどうすればよいですか?

   $.ajax({
      type: "POST",                            
       url: '@Url.Action("Action","Controller")', 
      data: { passedString: "Industrial"},           
      success: function(data){
           //pass data to ViewBag??
      }
});

私の見解:

@Html.DropDownListFor(model => model.TraumaCode, (SelectList)ViewBag.TraumaList)

私のコントローラーアクション:

    public ActionResult GetTraumaType(string passedString)
    {
        if (passedString == "Industrial")
        { 
        ViewBag.TraumaList = some Value...
        }
        else
        {
         ViewBag.TraumaList = another Value...
        }
    }

ページが一度読み込まれるため、ViewBag 情報を変更できないことは理解しています。DropDownList にデータを渡す別の方法はありますか?

4

2 に答える 2