Reputation: 1
I need to bind grid with linq to entity(asp C#), when Im binding I need to replace true or false with On or Off. how I can accomplish it?
ex.
var t = from k in entity.table select k.IsActive;
so in result if
IsActive == true I need to return On
IsActive == false I need to return Off
Upvotes: 0
Views: 488
Reputation: 1
try this
var t = from k in entity.table select k.IsActive.GetValueOrDefault() ? "On" : "Off";
Upvotes: 0
Reputation: 5150
Have you tried this?
var t = from k in entity.table select (k.IsActive ? On : Off);
Upvotes: 0
Reputation: 169143
var t = from k in entity.table select k.IsActive ? "On" : "Off";
Upvotes: 4