Visual studio 2012 我无法在mvc3中获取dropdownlist值

Visual studio 2012 我无法在mvc3中获取dropdownlist值,visual-studio-2012,model-view-controller,Visual Studio 2012,Model View Controller,我有一个dropdownlist元素的表单。我想得到控制器中dropdownlist的值。 我不知道怎样才能做到这一点。我在controller中读取了dataview用户的用户名,并希望通过dropdownlist选项更改他们的角色 @using (Html.BeginForm()) { <form name="register" action="#"> <div> <table> @foreach (MembershipUser us

我有一个dropdownlist元素的表单。我想得到控制器中dropdownlist的值。 我不知道怎样才能做到这一点。我在controller中读取了dataview用户的用户名,并希望通过dropdownlist选项更改他们的角色

@using (Html.BeginForm()) {
<form name="register" action="#"> 
<div>

  <table>

      @foreach (MembershipUser user in Model)
        {
            var userroles = Roles.GetRolesForUser(user.UserName);
              <tr>
                  <td>
                      @user.UserName
                  </td>
                  @foreach (var role in userroles)
                     {
                          <td>
                              @role
                          </td>
                    }

                  <td>
                       @Html.DropDownList("roleName")
                       @Html.ValidationMessage("roleName")

                  </td>
                  <td>
                  </td>
              </tr>
      }       

  </table>
<input type="submit" class="register" value="Save" />
</div>

    </form>

   }
您是否尝试过:

public ActionResult Index(string roleNameSelectedValue)
{
    // roleNameSelectedValue is the "Value" field of selected item in your dropdownlist
    return RedirectToAction("Index", "Home");
}

或者使用
@Html.DropDownListFor(m=>Model.roleName,ViewBag.roleName作为SelectList)

我尝试了这一点,并在带有response.write(rolenaseselectvalue)的页面上获得写入值错误
public ActionResult Index(string roleNameSelectedValue)
{
    // roleNameSelectedValue is the "Value" field of selected item in your dropdownlist
    return RedirectToAction("Index", "Home");
}