[SOLVED] Eval of ASP.Net is not using not equals

Issue

I need to disable a div for db data value which fetched from code behind but how i can achieve with below Equals code

Requirement : Not Equal("1") then disable div.

my code is below : instead of Equals in below code ,I have to use not Equals…..

 <div class="row" style='<%# (Eval("Test").ToString().Equals("1"))? "display:none;" : string.Empty %>'>

Solution

<div class="row" style='<%= ((Test != "1") ? "display:none;" : string.Empty) %>'>
    <h1>Lorem ipsum dolor sit amet ...</h1>
</div>

assuming Test here, is an instance public property of type string in the code-behind of your page.

Or this could work too :

<div class="row" style='<%# ((Eval("Test").ToString() != "1") ? "display:none;" : string.Empty) %>'>
    <h1>Lorem ipsum dolor sit amet ...</h1>
</div>

Answered By – Rivo R.

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *