Print Empty String when DataBinder.Eval is NULL

5k views Asked by At

I have the following in my repeater:

<div class="LabelHolderrepeatershort" style="font-size:10px"><%#DataBinder.Eval(Container.DataItem, "id")%></div>
        <div class="LabelHolderrepeatershort"><%#DataBinder.Eval(Container.DataItem, "Date", "{0:M/d/yy}")%></div>
        <div class="LabelHolderrepeater"><%#DataBinder.Eval(Container.DataItem, "Hours")%></div>
        <div class="LabelHolderrepeater"  style="font-size:10px"><%#DataBinder.Eval(Container.DataItem, "Note")%></div>
        <div class="LabelHolderrepeater"><%#DataBinder.Eval(Container.DataItem, "DateSubmitted")%></div>
        <div class="clear"></div>
    </div>

How can I print an empty string when Note is NULL because the DateSubmitted div is being displayed where the Note div when Note is NULL

1

There are 1 answers

0
Ehsan On

you can use ternary operator, like this

DataBinder.Eval(Container.DataItem, "Note") != NULL ? "SomeValue" : "Some other value"