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
80
Rookie question about DefaultCellValue property
posted

OK, so I'm showing a big grid that's bound to a data set and then I'm attaching a new column for a checkbox for item selection - pretty common scenario I'd think.  However I want the checkboxes to default to unchecked and for the life of me I can't get it to work.  they show up as checked but "gray" and evaluate to null.  You can check and uncheck them at which point they look "normal" and evaluate to true/false as you'd expect. 

 So is there a trick to the .DefaultCellValue = xxx that I'm missing here? 

thanks

Parents
  • 469350
    Offline posted

     Hi,

        DefaultCellValue only affects rows added by the user. If you have data in your grid and you are using an unbound column to show checkboxes, the DefaultCell Value won't help you there.

        My guess is that you are adding an unbound column to the grid and setting the Style on the column to CheckBox, but you are not setting the DataType. If you don't set the DataType, it defaults to string, so this will end up displaying as the indeteminate state in every cell. 

        What you should do is set the DataType on the column to bool. This will default the value of the cell to false and you don't need to set the Style on the column, since a bool column defaults to checkbox style

        Oh... and if you ever do need to initialze the value of an unbound column, the place to do it is in the InitializeRow. You would check to make sure e.ReInitialize is false, so you only set the value the first time.  

     

         

Reply Children