RadGridView CellStyleSelector Value==null

3 posts, 1 answers
  1. Mike
    Mike avatar
    4 posts
    Member since:
    Nov 2014

    Posted 10 Nov 2014 Link to this post

    Hi
    I have a RadGridView bound to a collection and I am adding the columns and their bindings manually in code-behind.
    One of the columns has a CellStyleSelector set which is checking the cell value for a negative value (and assigning a style to change the foreground color to red).
    This is all working fine when entering values into the grid (positive values are black and negative are red).
    However when the grid is initially loaded with data and the columns added, the negative numbers are black.
    This is happening because when the style selector is called the first time (after the data has loaded and columns added) the GridViewCell Value property is null.
    If I were to then click in a cell to make it go into edit mode and press enter, the style selector is called again - this time with a valid value - and the correct style is applied.
    As a test, if I refresh the bindings (notify all properties changed) on a timer after say 1 second, then the style selector is called again with correct values etc.
    So my question is: why is GridViewCell Value property null the first time and how can I overcome this?

    Thanks,
    Mike.

  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Nov 2014 Link to this post

    Hello Mike,

    Generally, you should work with the data items and the values of their properties rather than the Value of the cell. Could you verify whether you cannot modify your logic so that it counts on the data and not on visual elements ?


    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Mike
    Mike avatar
    4 posts
    Member since:
    Nov 2014

    Posted 12 Nov 2014 in reply to Maya Link to this post

    Hi Maya
    Thanks for your response.
    I have since modified my code to use a DataTrigger (binding to the underlying data) and it is all working now.
    Thanks,
    Mike.
Back to Top