0

I'm using GridMVC in my project, This code Show me 0 or 1 :

columns.Add(model => model.ETAT)
                            .Filterable(true)
                            .Titled("Etat")
                            .Sortable(true);

Etat can have only two value Zero or One. So Instead of Showing 0 or 1 I want to display good IF value it's 1, (etat = 1) ELSE show bad( etat = 0).

enter image description here

How to do it ?
Thank's.

2 Answers 2

1

I would add a ETATDisplay to my ViewModel so that it does the calculation on that backend.

something like

public class myViewModel 
{
    public int ETAT {get;set;}
    public string ETATDisplay 
    {
        get { return ETAT == 1 ? "Good" : "Bad";}
    }
}

Then it just should be the following on the view

columns.Add(model => model.ETATDisplay)
Sign up to request clarification or add additional context in comments.

Comments

1

Change your code to the following

columns.Add(model => (model.ETAT== 0) ? "bad" :"good")

8 Comments

Expression 'model => IIF((model.ETAT == Convert(0)), "bad", "good")'. not supported by grid any other way ?
I never used GridMVC but try IIF(!model.ETAT.Value, "bad", "good")
Like this : columns.Add(model => IIF(!model.ETAT.Value, "bad", "good")) ? it's not accepted I got error
And why he's trying to convert(0) Etat got decimal Type and 0 is Decimal they have same type
your datatype is BIT?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.