Asp.net mvc 4 从下拉列表中传递参数@using(Html.BeginForm)

Asp.net mvc 4 从下拉列表中传递参数@using(Html.BeginForm),asp.net-mvc-4,Asp.net Mvc 4,我有以下代码,我想从dropdownlist中传递所选值,当我提交按钮时,参数的值应该从selectedvalue而不是“1”中读取 @DropDownList(“ClientTypeId”,null,新的{@class=“table”,style=“宽度:70%;高度:100%;”) @使用(Html.BeginForm(“视图”,“客户端”,新的{ClientTypeId=1},FormMethod.Post,null)) { } 请在表单(@using(Html.BeginForm))标

我有以下代码,我想从dropdownlist中传递所选值,当我提交按钮时,参数的值应该从selectedvalue而不是“1”中读取


@DropDownList(“ClientTypeId”,null,新的{@class=“table”,style=“宽度:70%;高度:100%;”)
@使用(Html.BeginForm(“视图”,“客户端”,新的{ClientTypeId=1},FormMethod.Post,null))
{
}

请在表单(@using(Html.BeginForm))标记中添加您的下拉列表。您将获得您的数据。

请在表单(@using(Html.BeginForm))标记中添加您的下拉列表。您将获得您的数据。

my dropdownlist code:@Html.dropdownlist(“ClientTypeId”,null,new{@class=“table”,style=“width:70%;height:100%;”})您的下拉列表需要位于表单内部(并从表单中删除
new{ClientTypeId=1}
)谢谢,现在工作正常:)@using(Html.BeginForm(“查看”,“客户端”,FormMethod.Post,null)){@Html.DropDownList(“ClientTypeId”,null,new{@class=“table”,style=“宽度:70%;高度:100%;”})}@StephenMuecke,谢谢你,工作很好,但我想问你,我是否想传递很多参数,在我的例子中,我想将+的值传递给名为“ClientTypeId”的DropList的值,我该怎么做呢?然后您只需要为它添加一个输入。表单将发回所有成功控件的
name/value
对。我的dropdownlist代码:@Html.dropdownlist(“ClientTypeId”,null,new{@class=“table”,style=“width:70%;height:100%;”})您的下拉列表需要在表单中(并从表单中删除
new{ClientTypeId=1}
),谢谢,现在工作正常:)@使用(Html.BeginForm(“视图”,“客户端”,FormMethod.Post,null)){@Html.DropDownList(“ClientTypeId”,null,new{@class=“table”,style=”宽度:70%;高度:100%;“})}@StephenMuecke,谢谢你,工作很好,但我想问你,我是否想传递很多参数,在我的例子中,我想将+的值传递给名为“ClientTypeId”的DropList的值,我该怎么做呢?然后您只需要为它添加一个输入。表单将发回其成功控件的所有
name/value
对。
<td style="width:25%;">
    @Html.DropDownList( "ClientTypeId", null, new {@class="table",style="width: 70%; height:100%;"})
</td>
<td style="width:25%;">
</td>
<td style="width:25%;">
</td>
<td style="width:25%;">
     @using (Html.BeginForm("View", "Client", new { ClientTypeId =  1 }, FormMethod.Post, null))
     {
          <input type="submit" value="Search" class="btn btn-default"  />
     }
</td>