MVC Razor - If condition shows up in html render : <p>In below code(the first Div) I need to Put if condition based on which different buttons will be visible. I did this but it results in below issue (see pic below). We can't put if conditions in DIV ? Please suggest a way to do this. Thanks!</p>

<p><a href="https://i.stack.imgur.com/oNcbi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oNcbi.png" alt="enter image description here"></a></p>

<pre><code>&lt;td style="text-align:center; vertical-align:middle"&gt;  
                                    &lt;div class="editDelGLCode"&gt;
                                        if(@Model.Tables["PM_GLCode"].Rows[0]["InfoRefID"].ToString().Trim().Length == 0)
                                        {
                                        &lt;button type="button" class="btn OOrange" onclick="editGLCode(this);"&gt;
                                            &lt;i class="fas fa-plus-circle"&gt;&lt;/i&gt; Add New
                                        &lt;/button&gt;
                                        }
                                        else
                                        {
                                        &lt;a href="#" title="Edit" onclick="editGLCode(this);"&gt;&lt;i class="fas fa-edit"&gt;&lt;/i&gt;&lt;/a&gt;
                                        &amp;nbsp;&amp;nbsp;
                                        }
                                    &lt;/div&gt;
                                    &lt;div class="saveCanGLCode" style="display:none"&gt;
                                        &lt;span id="UpdateOSaveGLCode"&gt; &lt;a href="#" title="Save" onclick="addOrUpdateOGlcode(this);"&gt;&lt;i class="fas fa-save"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;
                                        &lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;
                                        &lt;span&gt;&lt;a href="#" title="Cancel" onclick="cancelRowGLCode();"&gt;&lt;i class="fas fa-times"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;
                                    &lt;/div&gt;
                                    &lt;div class="hdnPM_GLCode" style="display:none;"&gt;
                                        @if (Model.Tables["PM_GLCode"].Rows.Count &gt; 0)
                                        { @Model.Tables["PM_GLCode"].Rows[0]["BSAInfoRefID"]}
                                    &lt;/div&gt;
                                &lt;/td&gt;
</code></pre>
