Link to home
Start Free TrialLog in
Avatar of NickMalloy
NickMalloyFlag for United States of America

asked on

mvc5 different row color on table by value

I'm trying to change the row color of a table based on if statements. I've tried if else in razor, but I'm getting syntax errors.

@foreach (var item in Model.List)
                                            {
                                                DateTime dadate = item.G.StatusDate;
                                                TimeSpan days = dadate - DateTime.Now;
                                                if (days.Days < 1)
                                                {
                                                   @:
                                                    <tr class="info">
                                                }
                                                else
                                                {
                                                 @:   
                                                <tr class="warning">
                                                }


                                                <td>
                                                  @Html.DisplayFor(modelItem => item.G.RequestID)
                                                </td>
                                                <td>
                                                    @Html.DisplayFor(modelItem => item.T.ItemDescription)
                                                </td>
                                            </tr>
                                            }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial