简体   繁体   中英

Print Empty String when DataBinder.Eval is NULL

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

您可以使用三元运算符,像这样

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM