看法:
@using (Html.BeginForm("Index", "APIController",FormMethod.Post))
{
<select id="Segmentation" name="Segmentation">
@foreach (var item in Model.listofSegments)
{
<option>@item</option>
}
</select>
<input type="submit" value="Send" />
}
模型:
public class SegmentRepository
{
public List<String> GetSegmentation()
{
//I have the values in this
}
}
控制器:
public class APIController : Controller
{
public ActionResult Index(FormCollection formCollection)
{
dynamic mymodel = new ExpandoObject();
SegmentRepository segment = new SegmentRepository();
mymodel.listofSegments = segment.GetSegmentation();
String roleValue1 = formCollection["Segmentation"];
return View(mymodel);
}
}
我无法在 roleValue1
中获取选择选项值。
我想从 roleValue1
中获取值,并用它来触发我视图中的另一个下拉菜单。
原文由 Sid 发布,翻译遵循 CC BY-SA 4.0 许可协议
查看代码
控制器代码