I am developing a website using ASP.NET C # using a razor viewer mechanism. I use a for loop to display rows from a database and display them in an html table. each row contains a variable called "requestStatus". Request status is either “Approved,” “Rejected,” or “Pending.” Is there a way that I can change the bg color of a table row based on requeststatus, for example, if requeststatus is “expecting”, set the table row to yellow if the request status is “approved” in the row table of the bgcolor table
any help would be very great!
The code I use displays the table below
<fieldset>
<legend>Your Leave Requests</legend>
<table border="1" width="100%">
<tr bgcolor="grey">
<th>Description</th>
<th>Leave Type</th>
<th>Start Date</th>
<th>End Date</th>
<th>Total days leave requested</th>
<th>Request Status</th>
</tr>
@foreach(var rows2 in rows1){
<tr>
<th>@rows2.description</th>
<th>@rows2.leaveType</th>
<th>@rows2.startDate.ToString("dd-MMMM-yyyy")</th>
<th>@rows2.endDate.ToString("dd-MMMM-yyyy")</th>
<th>@rows2.totalDays</th>
<th>@rows2.requestStatus</th>
</tr>
}
</table>
</fieldset>