Asp.net mvc 在提交表单MVC时获取控制器上的下拉列表值

Asp.net mvc 在提交表单MVC时获取控制器上的下拉列表值,asp.net-mvc,forms,Asp.net Mvc,Forms,这是我的看法 @using (Html.BeginForm("uploadimage", "PatientDocumentsMain", FormMethod.Post, new { @Area = "PatientDocument", enctype = "mult

这是我的看法

    @using (Html.BeginForm("uploadimage",
                           "PatientDocumentsMain",
                            FormMethod.Post,
                            new { @Area = "PatientDocument", enctype = 
                            "multipart/form-data" }))
        {
         <table cellspacing="0" cellpadding="0"  class="table table-
          striped">
          <tr>
           <td>
              Document Name:<span class="spnError">*</span>
           </td>
           <td>
              <input type="text" id="txtDocumentName" name="DocName" 
                class="required form-control" />
           </td>
          </tr>
          <tr>
           <td class="tdEditDoc">
             <span>Document Type:</span><span class="spnError">*</span>
           </td>
           <td id="tdDocumentCategory">                 
            @Html.DropDownList("ddlDocumentCategory", null, new { @id = "", 
                               @onchange = "AddCategory();", @class = 
                               "required form-control", @name= "DocType" })
           </td>
          </tr>
          <tr>
            <td class="tdEditDoc">
              <span>Date:</span><span class="spnError">*</span>
            </td>
            <td>
              <input type="text" id="txtPatientDocumentDate" class="Date 
              required IsDate form-control" name="DocDate" />
            </td>
           </tr>
           <tr>
             <td class="tdEditDoc" style="height: 25px;">
               <span>Confidental:</span>
             </td>
             <td>
               <input type="checkbox" id="chkPatientDocumentIsConfedential" 
                />
             </td>
            </tr>
            <tr>
              <td class="tdEditDoc" style="vertical-align: top">
                Comments:
              </td>
              <td>
                <textarea id="txtPatientDocumentComments" name="comments" 
                style="margin-right: 15px; width: 245px; height: 69px; 
                border-width: 1px; border-color: #c4c4c4;resize:none" 
                class="form-control">
                </textarea>
               </td>
              </tr>
           </table>
    <input type="file" name="file" id="file" title="Upload file(s)" />
}

我正在获取除下拉值之外的所有其他参数。另外,如何获取复选框的值(是否选中)。我没有使用任何模型,想不使用它。

是否使用空值进行下拉绑定

 @Html.DropDownList("ddlDocumentCategory", null, new { @id = "", @onchange = "AddCategory();", @class = "required form-control", @name= "DocType" })
还要确保输入字段的名称和字符串参数相同

有用链接
第一个参数是字段的名称

@Html.DropDownList("DocType", null, new { @id = "", @onchange = "AddCategory();", @class = "required form-control" })

为什么要在post Action方法中创建这么多变量,我建议使用FormValues或Model。不能使用Model。如何使用FormValue?将ActionMethod中的参数替换为
public void uploadImage(FormCollection fomr)这是一本键/值字典。@AravindSivam谢谢兄弟!现在正在工作,所以我正在重写name属性。您的
具有
name=“ddlDocumentCategory”
,它与POST方法中的参数没有关系。停止手动生成html,使用模型(MVC中的
M
就是这个意思)并使用强类型的
HtmlHelper
方法绑定到您的模型(POST方法中的参数将是您的模型)
@name=“DocType”
什么都不做(它不会更改
name
属性)他不会将值绑定到下拉列表,输入的第二个名称必须与接收parmater()相同现在,通过使用“字符串状态”参数获取复选框的值,我还有reffer链接,即如何将表单发布到asp.net mvci的绑定下拉列表与Viewbag.ddlDocumentCategory。但这不是我的问题。我无法在控制器上获取值,这是由于名称属性冲突。
@Html.DropDownList("DocType", null, new { @id = "", @onchange = "AddCategory();", @class = "required form-control" })