Using ASP.NET razor and SQL Server 2008 R2
I have a local variable that is declared thus:
var tsmMtd = db.QueryValue("
SELECT b.Name, SUM(subtotal) totalSUM
FROM DR_TRANS a
INNER JOIN Staff b ON a.Salesno = b.Staffno
WHERE a.salesno in (12,23,28,30)
AND a.TRANSDATE >= dateadd(m, datediff(m, 0, getdate()), 0)
AND a.REF3 = 'Invoice'
GROUP BY b.Name
ORDER BY totalSUM DESC
");
Now that returns an array of names from the table, sorted by sales value. calling it in the HTML later as
@tsmMtd.ToString()
which prints the topmost name. OK, all good. NOW....
I need to format the text of the page based on that top salesperson. I want their name to go blue if they are the top salesperson.This is what I did on the 'actual sales' figure for a salesperson:
<span class=@(salesval12 > 6000 ? "blue" : "red")>@salesval12.ToString("C")</span>
This works fine to change the colour of the text if it is over the 6000 value. (classes red and blue are defined higher up the page). So, I did this:
<span class=@(tsmMtd = "CHARLIE JONES" ? "blue" : "red")>Charlie</span>
but it fails at loading saying Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'bool'
OK, so what I need to know is
- what I am doing wrong
- what I should be doing
Any and all help much appreciated.