Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 根据条件显示隐藏行_Html_Asp.net Mvc_List_Multi Level - Fatal编程技术网

Html 根据条件显示隐藏行

Html 根据条件显示隐藏行,html,asp.net-mvc,list,multi-level,Html,Asp.net Mvc,List,Multi Level,我在mvc中有一个列表视图。每个项目都有两个以上的列表和一个id。其中一个列表的类型与 原始列表是另一个数据列表。这适用于4个级别。乙二醇 List<myType>{id,List<myType>{...},List<dataType>} @foreach (var item in Model) { <tr id="lv0-@item.id"> <td>

我在mvc中有一个列表视图。每个项目都有两个以上的列表和一个id。其中一个列表的类型与 原始列表是另一个数据列表。这适用于4个级别。乙二醇

List<myType>{id,List<myType>{...},List<dataType>}
@foreach (var item in Model)
    {

        <tr id="lv0-@item.id">
            <td>
                @Html.DisplayFor(modelItem => item.id)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.name)
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <table>

                    @foreach (var item1 in item.myType)
                    {
                        if (item1.dataType!= null || item1.myType!= null)
                        {

                            <tr id="lv1-@item1.id">
                                <td>
                                    @Html.DisplayFor(modelItem => item1.id)
                                </td>

                                <td>
                                    @Html.DisplayFor(modelItem => item1.name)
                                </td>
                                <td>
                                </td>
                            </tr>
 <tr>
            <td colspan="3">
                <table>

                    @foreach (var item2 in item1.myType)
                    {
                        if (item1.dataType!= null || item2.myType!= null)
                        {

                            <tr id="lv1-@item1.id">
                                <td>
                                    @Html.DisplayFor(modelItem => item2.id)
                                </td>

                                <td>
                                    @Html.DisplayFor(modelItem => item2.name)
                                </td>
                                <td>
                                </td>
                            </tr>
                        }
                    }

                </table>
            </td>
        </tr>
                        }
                    }

                </table>
            </td>
        </tr>

    }
List{id,List{…},List}
@foreach(模型中的var项目)
{
@DisplayFor(modeleItem=>item.id)
@DisplayFor(modelItem=>item.name)
@foreach(item.myType中的var item1)
{
if(item1.dataType!=null | | item1.myType!=null)
{
@DisplayFor(modeleItem=>item1.id)
@DisplayFor(modelItem=>item1.name)
@foreach(item1.myType中的var item2)
{
if(item1.dataType!=null | | item2.myType!=null)
{
@DisplayFor(modeleItem=>item2.id)
@DisplayFor(modeleItem=>item2.name)
}
}
}
}
}
问题是可能没有2、3、4级列表,并且可能在某些级别项目中没有数据列表, 我正在寻找的解决方案是,如果myType列表项没有子项,并且没有数据类型列表,则隐藏这些行