Scott Hanselman

Angst, ISO Standards, DataBinding Eval(), Malaise, DataGrids, System.Globalization, Fritz and the morning after...

May 29, 2003 Comment on this post [1] Posted in Web Services | ASP.NET | Javascript | Internationalization | XML
Sponsored By

Not much blogging this week...here's what I've been rambling about lately.

The DataGrid

I've had my head down in ASP.NET and the Data Grid control.  Our eFinance Application Server makes extensive use of what I like to call "strongly-typed XML" (XML with associated XSDs/XML Schema) and I've been doing lots of lovely DataGrids with Sorting, Filtering, etc as well as some dynamic charts. 

Globalization

I'm also deep in my most favorite (or is that favourite?) namespace, System.Globalization.  It's just so well thought out.  Lots of great stuff in here and much use of ISO standards like ISO 4217 for currency and number formatting (JPY, USD, GBP, ZWD, etc) and ISO 3166 for country codes (JP, US, GB, ZW, etc)...see a pattern?  I'm one of those dorks that dug the Dewey Decimal System and I dig nice ordered category systems now. 

One interesting thing, I'm running into a bit of trouble with number formatting, which I would have preferred to relegate entirely to the ASPX page...as if the ASPX page were truly the "View" to my Code-Behind "Controller."  While that's the dream, it's hardly the reality.  This kind of formatting creeps into my code-behinds, and leaps in to them when dealing with culture-specific data input.

A not-quite-perfect-pattern

Things get so mixed up between ASPX and Code-Behind on a moderately complex ASP.NET page (considering a multi-lingual site and multi-currency-in-one-grid situation), once you factor in DataBinding Eval() statements, Totals in Footers, Sorting and Filtering, it really makes me question the whole ASP.NET code-behind paradigm.  Sometimes my DataGrid event handlers feel better on the OnEventWhatever attributes of the DataGrid tag in the ASPX, and sometimes I just hook them up ala C# += EventHandlers in InitializeComponent().  Even Dino Esposito, a prolific writer on the DataGrid, puts page formatting all over the place in code-behinds (at the bottom) in his articles (although I take all article code with a mountain-sized grain of salt) apparently because there's just no other way to do it.

Is elegance possible?

Perhaps I've tried to fit too many hopes and dreams in a DataGrid and I should just grin and bear the tragic inelegance of it all.  After ten-plus years of Web Development [ah, I long for the days where I was 00001.0003@compuserve.com, ;) ] perhaps some higher power is trying to hint to me that rich cross-browser UIs just can't be truly "elegant" on what is perhaps a fatally flawed super-stateless HTML/QUIRKSMODE/HTTP/DOM/JAVASCRIPT/BAILINGWIRE base? 

Or...

alternately, it's 1am and time for bed.  In conclusion, I will say this: I can get more done in ASP.NET in a day than I could in Classic ASP in a fortnight and I don't have that lingering sense of next-morning shame that came with a truly horrendous ASP hack - and Fritz Onion played no small part in this personal achievement.

Today's Query

Other than building my own reverse-lookup hashtable at Application.Start, does anyone seen an obvious (or not obvious) and fast way given a currency string ("USD", etc) to get a CultureInfo and a NumberFormatInfo?  Perhaps I'm missing something obvious.

UPDATE: Peter Provost has a eye-opening reply post about this topic that makes a lot of sense to me.  If I start thinking about ASPX files and code-behinds as two sides of the same coin, then more "classical" MVC architectures fit nicely into the ASP.NET model.  I was stuck on what I felt was lack of elegance in interface between the two.  I'll try suspending belief for a bit and see what comes of it... :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
May 29, 2003 20:32
I think the problem is in thinking of code-behind files as controllers. Even though the PAG seems to think this is a good idea, as you're finding it doesn't work. For a longer version of this response, see my post here.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.