当表内容根据下拉列表更改时,我希望从表的第一行获取“Name”的值。目前,这在页面首次加载时有效。但是当下拉列表更改时我想要name
值。
控制器
public ActionResult ABC()
{
SDetails sDetails=new SDetails();
var model = new ClsA();
string name = sDetails.Rst().FirstOrDefault().Name;
model.firsts = sDetails.Rst();
model.seconds = sDetails.Rs(name);
return View(model);
}
查看
@model Aplication.Models.ABC.ClsA
@Html.DropDownListFor(m => m.drpList, new List<SelectListItem>
{
new SelectListItem {Value = "ls", Text="Laa" },
new SelectListItem {Value = "ms", Text = "Maa"},
},new { @id = "CountryList"})
<div id=myA>
@{ Html.RenderPartial("_PartialA", Model.firsts); }
</div>
<div id=myB>
@{ Html.RenderPartial("_PartialB", Model.seconds);}
</div>
_PartialA
@model IEnumerable<Aplication.Models.ABC.first>
table>
<tr>
<th>@Html.DisplayNameFor(m => m.Name)</th>
<th>@Html.DisplayNameFor(m => m.Address)</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>@Html.DisplayFor(modelItem => item.Address)</td>
</tr>
}
</table>
_PartialB
@model IEnumerable<Aplication.Models.ABC.second>
<table>
<tr>
<th>@Html.DisplayNameFor(m => m.Details)</th>
<th>@Html.DisplayNameFor(m => m.Age)</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Details)</td>
<td>@Html.DisplayFor(modelItem => item.Age)</td>
</tr>
}
</table>