Check out this code snippet (focus on rowspan="6"
- it's causing an issue:
<table>
<thead>
<tr>
<td>Ingredient</td>
<td>Qty (gm)</td>
<td>% of Capsule</td>
</tr>
</thead>
@foreach (var i in Model)
{
if (Convert.ToDecimal(i.Qty) < 0)
{
<tr>
<td style="border: 1px solid red; color: red;">@i.Ingredient</td>
<td style="border: 1px solid red; color: red;">@i.Qty</td>
</tr>
}
else if (Convert.ToDecimal(i.Qty) == 0m)
{
continue;
}
else
{
if (i.Ingredient.Contains("Active"))
{
<tr>
<td>@i.Ingredient<br />
<input type="text" name="@i.Ingredient" id="@i.Ingredient" /></td>
<td>@i.Qty</td>
@if (i.Percent != 0m)
{
<td rowspan="6" style="text-align: center;">@i.Percent.ToString("#.##")</td>
}
</tr>
}
else
{
<tr>
<td>@i.Ingredient</td>
<td>@i.Qty</td>
@if (i.Percent != 0m)
{
<td style="text-align: center;">@i.Percent.ToString("#.##")</td>
}
else
{
<td></td>
}
</tr>
}
}
}
<tr>
<td></td>
<td>Total %:</td>
<td style="text-align: center;">@Model.Sum(j => j.Percent).ToString("#.##")</td>
</tr>
</table>
Here's what the above code generates:
I'm trying to center align the cell with the value 9.74 within the 6 rows, as shown in the screenshot with the red arrows. What am I missing here?