asp.net mvc - Razor If-condition not working -
i can't seem if-condition of string comparing work. here code foreach block.
@foreach (var item in model){ <tr onclick="getdata('@item.discountdescs');"> <td></td> <td>@html.displayfor(modelitem => item.discountdescs)</td> <td> @if (string.equals(item.discountform, "c")) { @:card } else { @:other } </td> <td>@html.displayfor(modelitem => item.discounttype)</td> <td>@html.displayfor(modelitem => item.discountmode)</td> <td>@html.displayfor(modelitem => item.discountvalue)</td> <td>@html.displayfor(modelitem => item.isactive)</td> <td>@html.displayfor(modelitem => item.isscheme)</td> </tr> }
the td display "other".
you need trim value coming database.
use trim()
function
item.discountform.trim()
this omit spaces , compare string.
asp.net-mvc if-statement razor
No comments:
Post a Comment