Wednesday, April 19, 2006

Test with lots of data

I forgot to do this and it came back to bite me after deploying an ASP.NET 1.1 web application with a tabbed interface. Each tab on the page main.aspx contains a derived DataGrid with different columns. The DataGrids are created using the factory pattern based on which tab is active and currently displayed. The DataGrid that is returned from the factory is set to a page level DataGrid object. Testing proved that the user could navigate from tab to tab and page within the DataGrids. After deployment, however, ArgumentOutOfRangeExceptions were sometimes thrown after certain combinations of tab navigation and paging. Very quickly I realized that I needed to reset the DataGrid's CurrentPageIndex to zero after navigating to a new tab. This was necessary because the page DataGrid object persisted the CurrentPageIndex between tab clicks. More specifically, a condition could exist where Tab 1 had a DataGrid with 2 pages and Tab 2 had a DataGrid with 10 pages. If a user navigated to page 5 of Tab 2 and then back to Tab 1 then an exception was thrown because Tab 1 didn't have a page 5.

The production environment had at least 10 times the amount of data than our development environment. If I had better prepared the development environment to mirror production I wouldn't have had this post-deployment problem.