0

我创建了一个局部视图

@model chPayroll.Models.HREducation.HRInfo
 @{
      var list = (IEnumerable<SelectListItem>)TempData["PassedDivision"];
      var list1 = (IEnumerable<SelectListItem>)TempData["Country"];
 }
 <table >
       @Html.HiddenFor(x => x.StaffId)
   <tr>
    <td>@Html.DropDownListFor(x => x.Country, list1, "-select-",null)</td>
    <td>@Html.TextBoxFor(x => x.Board)</td>
    <td>@Html.TextBoxFor(x => x.Level)</td>
    <td>@Html.TextBoxFor(x => x.PassedYr)</td>
    <td>@Html.DropDownListFor(x => x.PassedDivision, list, "-selected-",null)</td>
    <td><input type="file" name="file" /></td>
   </tr>
</table>

我从控制器多次调用这个局部视图

[HttpGet]
        public ActionResult BlankEditorRow(string search)
        {
            HRInfo aa = new HRInfo();
            TempData["PassedDivision"] = extract.getDivision();
            TempData["Country"] = extract.getCountry();
            aa.StaffId=(Convert.ToInt16(search));
            return PartialView("ViewUserControl1",aa);

        }
   [HttpPost]
   public ActionResult BlankEditorRow(HRInfo ob)
   {
     extract.SaveEdu(ob);
    }

我可以一次获得一个值,即当局部视图被调用时,它工作正常。但是当我必须从两个或多个局部视图中获取值时它不起作用。有没有办法一次获取多个数据?

4

1 回答 1

0

I'm using this in some of my codes, wish it can help:

@Html.TextBox(Model.ID + ".Country", Model.Country)
...

so when i want to get value from multi values, just use the UpdateModel(myModel, Model.ID.ToString()).

Is that what u need?

于 2012-12-22T02:05:05.413 回答