0

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 %>'>
VimalSingh
  • 237
  • 2
  • 4
  • 16
  • You could switch the cases in your conditional so that it outputs `string.Empty` when the value equals "1". – Jack A. Feb 07 '22 at 17:06

1 Answers1

3
<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>
Rivo R.
  • 351
  • 2
  • 8