2
Reply

ASP.NET Razor - C# Logic Conditions

ashish sadasing

ashish sadasing

Feb 2 2016 8:08 AM
332
Hello guys,
 
I have a query and according to the result found, i am checking if it matches a specific string.(simple conditional statement)
Depending on its boolean value, i am assigning certain html to the variable and finally tring to display it on the interface.
 
The problem is that my query result is "NORTH" and my specific string is also "NORTH", so why it is not displaying.
 
Is there a problem with my conditional statement? beacause i have uses ==  and i am not sure if it is ok.
Can u please check it out. :( hop you can help me out. Below are the codes : 
 
//defining variable
 
var flag = ""; 
 
//sql
 
var selectCustomers = db.Query("SELECT * FROM Customers");
 
//condition 
foreach (var row in selectCustomers) {                                 
   if (row.Customer_address == "NORTH") {
      Flag = "<span class='label label-success'>OK</span>";
   } else if (row.Customer_address == "SOUTH") {                                     
      Flag = "<span class='label label-danger'>NOK</span>";                               }
}
//Display in table
<td>@Html.Raw(processFlag)</td>


 

 

Answers (2)