Vibrant discussion about CSLA .NET and using the framework to build great business applications.
Yesterday I wrote about performance problems with databinding and after tearing out what little hair I have left, I FINALLY figured out what the problem was.Thanks to an article on msdn:http://msdn2.microsoft.com/en-us/library/ha5xt0d9.aspxThe number one performance trick on this page says to avoid using formatting at the cell level (i.e., going into the column properties on the grid and setting it to C to format the number for currency). This includes setting the numeric formatting, which I've done on most of my cells. To remove the formatting you have to actually remove the column and re-add it. When you set formatting it makes a new instance of the default cell style to use. So, I've got 9 columns with 'other than default' settings. Once I removed the formatting.... waahhla!
They also recommend trapping the cell formatting event, which I did. I noticed that the event is fired constantly during load, so I added the “if _loading = true then exit sub” trick to only have it fire after everything else is done. This helped a little.Another biggie for me was that I had ‘autoresizecolumns’ set. I set it to none, then made a single call to MyDatagrid.AutoResizeColumns(DisplayedOnly).My grid loads in a mere 2 seconds, instead of 30, including fetching the collection with about 2000 items!!! I love that it’s faster and I never dreamed it would be this fast.I hope this helps someone out. I've spent no less than 8 hours on this one item. Sometimes fixing a bug like this is so satisfying. :-)
I am just beginning with CSLA, so this might be a really stupid question. How do you format the cell to show just a date with a datetime field if you cannot use the column properties for formatting?
internally within your library you should declare all of your datatime types as SmartDate. The property from your library, however, returns a string for the date. In your get you return: return _smartDate.Text. You can see the ProjectTracker for example library props.
If the date doesn't have a value then your datagrid will show a blank string. Also, you won't need to format anything on the grid. If you want to show time or something in addition to the date then add another property in your library. This is much much easier than trying to get the datagrid to format it. Besides, you'll probably want to use it somewhere else in your app if you're using it here.