mvc 4剃须刀动态表格单元格

时间:2014-08-30 15:41:04

标签: asp.net asp.net-mvc-4

你好,请你帮帮我

在我看来,我有这张表:

<table style="width: 100%;">
  <tr>
    <td>@Html.DisplayName("idOperation")</td>
    <td>@Html.DisplayName("NameOperation")</td>
  </tr>
  <tr>
    <td>
      <select id="Operation" class="sltStyle">
        @foreach (var item1 in ViewBag.Operations)
        {         
          <option>@item1.Id_Operation</option>           
        }
      </select>
    </td>
    <td>
    </td>
  </tr>
</table> 

控制器

public class testController : Controller
{
  private RendementEntities db = new RendementEntities();
  public ActionResult PartialViewDemo()
  {
    List<Operations> allOperations = db.Operations.ToList();
    return View(allOperations);
  }
  public ActionResult NomOperation(int idOperation)
  {
    IEnumerable<Operations> allOperations = db.Operations.ToList();
    var selectedOperationId = (from c in allOperations where c.Id_Operation == idOperation select c.Id_Operation).FirstOrDefault();
    var NameForId = (from a in allOperations where a.Id_Operation == selectedOperationId select a.Designation).FirstOrDefault();
    return PartialView("_OperationsPV" , NameForId);
  }
}

当用户选择idOperation(onclick)时,是否可以自动生成nameOperation?

谢谢

0 个答案:

没有答案