0
@using (Html.BeginForm("testingMethod","test",FormMethod.Get)) {
@Html.AntiForgeryToken()

@foreach (var item in Model) {
    @Html.DropDownList("dropDown_"+item.ConfigCode+"_ListName", (IEnumerable<SelectListItem>)ViewData["dropDown_"+item.ConfigCode])
}
                    .
                    .
                    .
                    .
}
<input type="submit" value="Save" />

上記のコードに基づいて、「testController」で URL を返すメソッド「testingMethod」を正常に呼び出します。

http://localhost:59512/test/testing?__RequestVerificationToken=xxxxxxx&dropDown_KKK=3

私の ActionResult "testingMethod" で、この dropDown_KKK 値 3 を取得する必要があります。メソッドで何をすればよいでしょうか? 以下のようにtestingMethodを編集してみました:

public ActionResult testing(FormCollection collection){
    Debug.WriteLine(" ======= " + collection.GET("dropDown_KKK"));

}

他の投稿に基づいて、それは動作するはずですが、System.Web.MvC.FormCollection に GET の定義が含まれておらず、最初の引数 blablabla を受け入れる拡張メソッド 'GET' がないと言う collection.GET でエラーが発生します...

4

1 に答える 1

0

以下を使用できます。

collection["name"]

ドロップダウンリストの名前はどこにあるnameはずです。

于 2013-08-30T07:44:13.743 に答える