Drawing Blanks

Premature Optimization is a Prerequisite for Success

Archive for June 2012

Microsoft promoting anti-patterns

leave a comment »

Found this today in production code that I needed to modify:

… = ((TextBox)(row.Cells[1].Controls[0])).Text;
… = ((TextBox)(row.Cells[2].Controls[0])).Text;
… = ((CheckBox)(row.Cells[3].Controls[0])).Checked;

This was in a GridView.RowUpdating handler, and the change that I needed to make was adding a couple of columns to that grid.

Of course, I refactored the code in that page, and, of course, I found that all pages in the project are copy-paste-contaminated by that terrible pattern.

I did some lurking on google for grid view “best practices” and found something that is likely the origin of the infection:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowupdating.aspx

Written by bbzippo

06/08/2012 at 4:53 am

Posted in Uncategorized