So, you want to hide the image if certain data has certain value. You, can simply compare the value and apply a css
class as hidden to that element like:
First, add this css
in the head
element.
.d-none {
display: none !important;
}
Then replace your image control with this markup:
<asp:ImageButton runat="server" ID="imgInfo" CssClass='<%# Eval("SomeColumn") == DBNull.Value ? "d-none" : "" %>' ImageUrl="~/Images/info-note.png" tooltip='<%# Eval("user_address").ToString().Trim() %>' style="position: center; top: 3px; padding-right: 3px; padding-left:5px;cursor: help;" />
You can replace SomeColumn
with the database column that contains your value to be compared and I just compared if it was null, you can do other comparisons as well.
UPDATE
You can add another clause in the comparison and we can use string.IsNullOrEmpty()
method to check if the varchar
column is empty.
<asp:ImageButton runat="server" ID="imgInfo" CssClass='<%# Eval("SomeColumn") == DBNull.Value || string.IsNullOrEmpty(Eval("SomeColumn").ToString()) ? "d-none" : "" %>' ImageUrl="~/Images/info-note.png" tooltip='<%# Eval("user_address").ToString().Trim() %>' style="position: center; top: 3px; padding-right: 3px; padding-left:5px;cursor: help;" />
CLICK HERE to find out more related problems solutions.