首页 > 解决方案 > 如何应用分页符

问题描述

我试图从表格中跳过我的 TR,但我无法应用它。如果我的页面等于 1 并且 countSeq = 2,那么它会设置 always 的值。跳到下一页。

我正在努力:

 <table class="table table-striped table-itens-pedido-report">
                            <thead style="border: none !important;">
                                <tr style="border: none !important">
                                    @if (ViewBag.bSeqProduto == true)
                                    {
                                        <th style="width:3% !important ; border: none !important;font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;font-weight: 600 !important;font-size: 12px !important;">SEQ</th>
                                    }
                                    @if (ViewBag.bImagemProduto == true)
                                    {
                                        <th style="width:5% !important ; border: none !important;font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;font-weight: 600 !important;font-size: 12px !important;">IMAGEM</th>
                                    }

                                   
                                    @if (ViewBag.bTotalProduto)
                                    {
                                        <th style="width:8% !important ; border: none !important ; text-align:center !important;font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;font-weight: 600 !important;font-size: 12px !important;">TOTAL</th>
                                    }

                                </tr>

                            </thead>

                            @{int contadorSeq = 0;}
                            <tbody>
                                @foreach (var item in agrupar.Distinct())
                                {
                                    string classPageBreak = "always";
                                    if ((pagina == 1 && contadorSeq == 2) || contadorSeq >= 1)
                                    {
                                        classPageBreak = "always";
                                    }

                                    <tr style="border: none !important;     page-break-after: @(classPageBreak) ">

                                        @if (ViewBag.bSeqProduto == true)
                                        {
                                            <th style="font-size: 13px !important; width:3% !important ; text-align:center">@contadorSeq</th>
                                        }
                      </tr>
                      </table>

在此处输入图像描述

总结问题,我需要从tr跳,编程逻辑是工作的。

标签: c#html

解决方案


您必须在文档头中插入一些样式

<head>
    <style>
        @media print {
            tr.page-break  { display: block; page-break-before: always; }
        }   
    </style>
</head>

这是描述它的答案

将“page-break-before”应用于表格行 (tr)


推荐阅读