【问题标题】:One Column values will be changed when header DropdownListFor is getting changed - in mvc razor view c#当标题 DropdownListFor 被更改时,一列值将被更改 - 在 mvc razor 视图中 c#
【发布时间】:2017-04-15 07:35:28
【问题描述】:

刚接触这类工作,需要你的帮助

在我看来.cshtml ----

<table class>

                <thead>
                    <tr>
                        <th >@Html.CheckBox("IsAllRowSelected")</th>
                        <th >
                            @Html.DropDownListFor(m => m._dropDownForcolumn2, new List<SelectListItem>
                   { new SelectListItem{Text="option1", Value="option1"},
                       new SelectListItem{Text="option2", Value="option2"},
                       new SelectListItem{Text="option3", Value="option3"}
                     }, new {@id="dropDownForcolumn2" })
                        </th>
                        <th>@Html.Label(" column 3 ")</th>
                        <th>@Html.Label("column 4")</th>
                        <th>@Html.Label("column 5")</th>

                    </tr>
                </thead>
                <tbody>
                    @foreach (Models.MyModelClass item in Model._List)
                    {
                        <tr>
                            <td>@Html.CheckBox("IsEachRowSelected")</td>
                            <td>@item.Option1Values</td> 
 @*//@item.option2values; 
@item.option3vlaues;*@
                            <td>@item.column3value</td>
                            <td>@item.column4value</td>
                            <td>@item.column5value</td>

                        </tr>
                    }

1 .cant 再次发回控制器以仅获取此列值。它只是一个大页面中的一个小表 2 我已经在项目中有其他值 现在只有 option1 值出现在列中,要求是绑定第 2 列与标题下拉列表并选择第 2 个选项,然后这将显示@item.option2values 和第 3 个选项,然后将显示@item.option3values

其他栏目不会改变或触摸。

类似的东西

<td>
      if(dropdownvalue = option1)
       @item.Option1Values
elseif(dropdownvalue == option2 )
     @item.option2values 
elseif(dropdownvalue == option2 )
    @item.option3vlaues
</td>

ajax , jquery 是允许的,但不允许整页发布或部分视图发布

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-4 razor asp.net-ajax


    【解决方案1】:

    这样做 将 onload 方法放在表标签中

    function load()
    {
    
        $('.MyProperty2').hide();
        $('.MyProperty3').hide();
    }
    
    function Filldropdown(){
    
    
        var value = $('#dropdownID :selected').text();
    
    
        if (value == 'option1') {
    
            $('.MyProperty1').show();
            $('.MyProperty2').hide();
            $('.MyProperty3').hide();
    
        } else if (value == 'option2') {
            $('.MyProperty2').show();
            $('.MyProperty1').hide();
            $('.MyProperty3').hide();
    
        } else if (value == 'option3')  {
            $('.MyProperty3').show();
            $('.MyProperty2').hide();
            $('.MyProperty1').hide();
    
    
        }
    
    
    }
    

    【讨论】:

    • 这就是我要找的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多