locked
formatting float & null in a WebGrid RRS feed

  • Question

  • User379720387 posted

    grid.Column("Start_Level", "Start Level (inch)", style: "trclk", format: @<text>@item.Start_Level.ToString("#.0")</text>),

    The query returns a column which either has a float or NULL.

    All is fine with the formatting if the item has a float, but it all falls apart on a NULL

    The addition of a ternary operator results in many sqiggles.

    Tuesday, October 6, 2015 5:40 PM

Answers

  • User-821857111 posted

    Try 

    format: @<text>@(item.Start_Level != null ? item.Start_Level.ToString("#.0") : null)</text>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 7, 2015 2:21 AM