每当表内容根据下拉列表更改时,如何从表的第一行获取“名称”的值?

时间:2018-05-08 22:16:24

标签: asp.net-mvc

当表内容根据下拉列表更改时,我希望从表的第一行获取“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>

0 个答案:

没有答案