Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
895
Convert grid cell display values 'true/false' into 'Yes/No'
posted

I'd like to change what the user sees in the grid. Let's say I have a boolean column that is showing 'true' or 'false' and I'd like to show 'Yes' or 'No' instead. 

I seem to be able to accomplish this somewhat by placing some code in the InitializeRow event.

Like...

GridRecordItem activated = e.Row.Items.FindItemByKey("Activated");

            if (activated != null)

            {

                if ((bool)activated.Value == false)

                    activated.Text = "No";

                if ((bool)activated.Value == true)

                    activated.Text = "Yes";

            }

 

This seems to work, however if I edit a different value in the row and move to another row the formatting on the 'Yes/No' reverts back to 'true/false'.

So, it seems that after a row has been updated I need to reapply the formatting.

Where is the appropriate place to format the display value of a cell? 

Thanks,

Brian.