2

so I am doing the datasource export to excel, but i open the file i saw the column has checkbox instead of value true or false. how do i fixed this, indeed, i want to put a sting "active" or "inactive" depends on the value. how can i do that?

also i want to have string format for the phone number as well

and the code i have for model

  public string MobileNumber { get; set; }
  public bool? IsActive { get; set; }

how do i change in order for me to have the way that i want it ?

3
  • Have you tried converting your nullible boolean to a string before exporting? Commented Oct 17, 2012 at 20:34
  • how does that implement? Commented Oct 17, 2012 at 20:38
  • Where are you getting the data from? A SQL query? Commented Oct 17, 2012 at 20:44

1 Answer 1

2

Modify your model to return string for the IsActive property (or alternatively have two, one with bool and another with string). Then return the string value in the Linq query. Something like this:

from x in someTable
select new Model
    {
     .
     .
     .
     IsActive = (isActive ? "True" : "False");
     .
     .
    }
Sign up to request clarification or add additional context in comments.

4 Comments

Similar solution for formatting the phone number, have the model format the retrieved data.
hows the phone number differ from the isactive ?
@System Down, sadly when i did IsActive = u.isActive ? "True" : "False" --- give me error about the : operator, do u know why ?
@cool_spirit - Why not open a new question? Put the full code there and the exact text of the exception.

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.