Home > Enterprise >  How to hide particular li item with condition using html of table in c#
How to hide particular li item with condition using html of table in c#

Time:10-21

I have a table. I need to hide details on condition. I'm tried but didn't get the solution. Please help me. bellow is my code

  private string GenerateInvoiceTable(IInvoiceResponeForPdf invoice)
        {
            return $@"<table  style='width:120mm;font-size:20pt;font-family:tahoma;border-collapse:collapse;'>
                        <thead> 
                             <div style='text-align:center; width:25%'>
                             <ui class='list-unstyled'>
                                    <li style='font-weight:bold;'>Ramkrishna </li>
                                    <li>Begum Bazar,</li>
                                    <li>Hyderabad - 500012,</li>
                                    <li>Telagana, Code : 36,</li>                               
                                    **<li style='visibility: ${invoice.InvoiceType != "Estimation"} ? $'visible' : $'hidden''>M: 1234567898,Ph: 040-2222222,</li>
                                    <li>GSTIN: abcdezjsj. </li>**                                                                                               
                             </ui>
                            </div>
                            <div style='text-align:center; width:25%'>
                             <h4>Retail Invoice </h4>
                            </div>
                       </thead>                             
                        {GenerateInvoiceTableBody(invoice)}
                        {GenerateInvoicefooter(invoice)}
                    </table>";
        }

I tried different approaches but didn't get the solution. I need to hide contact numbers and gstin number if invoice type is "estimation". please help me

CodePudding user response:

Enclose the expression in parentheses

<li style='visibility: {(invoice.InvoiceType != "Estimation" ? "visible" : "hidden")}'>M: 1234567898,Ph: 040-2222222,</li>
  • Related