下拉菜单不将数据传递给控制器

Drop Downs not passing data to controller

我已经设置了一个带有表单的模式来将数据传递到我的控制器中。

<div class="container">
<div class="modal fade" id="modalcreate" tabindex="-1" role="dialog" aria-labelledby="createGroup" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
                <h4 class="modal-title text-center">Create a New Instance</h4>
            </div>

            <div class="modal-body" style="text-align: center">
                <div class="row">
                    <div class="modal-body" style="text-align: center">
                        <form action="/Home/CreateInstance/" method="POST">
                            <div class="form-group">
                                <label for="amiId">AMI ID:</label>
                                <select class="form-control text-center" id="amiId" style="margin: 0 auto">
                                    <option>ami-8519a9f6</option>
                                    <option>ami-8b8c57f8</option>
                                </select>
                                <label for="keyPairName">Key Pair Name:</label>
                                <input name="keyPairName" class="form-control text-center" type="text" placeholder="Conners Key" style="margin: 0 auto">
                                <label for="instanceType">InstanceType:</label>
                                <select class="form-control text-center" id="instanceType" style="margin: 0 auto">
                                    <option>InstanceType.T1Micro</option>
                                </select>
                                <label for="minCount">Minimum Instance Number:</label>
                                <input name="minCount" class="form-control text-center" type="text" placeholder="1" style="margin: 0 auto">
                                <label for="maxCount">Maximum Instance Number:</label>
                                <input name="maxCount" class="form-control text-center" type="text" placeholder="1" style="margin: 0 auto">
                                <label for="groups">Security Groups Attached:</label>
                                <select class="form-control text-center" id="groups" style="margin: 0 auto">
                                    @foreach (var groups in Model.groups)
                                    {
                                    <option>@groups.GroupName</option>
                                    }
                                </select>            
                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-success btn-lg" style="width: 100%;"><span class="glyphicon glyphicon-ok-sign"></span> Create</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

但由于某些原因,控制器中的方法仅接收文本框数据。根据 W3 bootstrap 输入,我已正确设置它们 http://www.w3schools.com/bootstrap/bootstrap_forms_inputs.asp

有人可以告诉我我似乎缺少什么吗?

您的 <select> 元素没有 name 属性,因此未提交它们的值。

我建议您使用强类型 HtmlHelper 方法绑定到您的模型并生成您的 html,这将添加正确的属性(@Html.BeginForm()@Html.LabelFor() , @Html.TextBoxFor()@Html.DropDownListFor()).