通过单击另一个Droplist.for来填充Droplist.for

时间:2019-05-15 15:43:35

标签: c# html model-view-controller

当我从另一个DropList.For中选择一个项目时,我正在尝试填充DropList.For。到目前为止,这是我的代码:

@Html.LabelFor(m => m.Cliente, new { @class = "control-label col-md-2" })
                            @Html.DropDownListFor(model => model.SelectedCategoryId,
                                    new SelectList(Model.Cliente, "CategoryId", "CategoryName"), "- Please Select -")
                            @Html.ValidationMessageFor(x => x.Cliente, null, new { @class = "label label-danger" })

                            @Html.LabelFor(m => m.Tipo_servicio, new { @class = "control-label col-md-2" })
                            @Html.DropDownListFor(model => model.SelectedCategoryId,
                                    new SelectList(Model.Tipo_servicio, "CategoryId", "CategoryName"), "- Please Select -")
                            @Html.ValidationMessageFor(x => x.Tipo_servicio, null, new { @class = "label label-danger" })

因此,我将其保存在视图中并用EntityFramework填充

1 个答案:

答案 0 :(得分:0)

您可以使用“ onChange”事件,可以检查以下链接。

  1. 对多个Dropdown使用相同的方法: same method for multiple ddl

  2. 不同下拉菜单的不同方法: enter link description here

谢谢