Be the first to write a review
Formatting Data in a DataGrid for ASP.NET 1.x
So you’ve built yourself a nice little application, you have some cool design patterns implemented, you’ve normalized your database, you have some pretty good CSS layout classes, maybe even a couple user controls for navigation menus, but there’s just one problem remaining: Data presentation.
The trouble is that your data storage is not directly representative of how your users want to view information. A database isn’t really supposed to be used as the place where you “pretty-up” your data presentation. The goal of the database is to just be your work horse. Let it store the data raw and untouched, and massage the presentation after the fact.
Databases often store data in their own format and for the most part you won’t even have control over how it decides to store it. We’ll use SQL Server in this tutorial as our example database. SQL Server can do all kinds of unwanted things to your data when it stores it. One of the most common things is to append 12:00 AM to your date columns unless you manually trim off the data before insertion.
So what happens when you return the data to the user unformatted? They see big ugly 12:00 AM tied to the end of every date in your DataGrids. It takes up space and is completely useless to the user. Unless your date is supposed to store time as well you need to format the dates correctly for the user.
Kevin Koch
Kevin Koch is a senior software engineer with over 8 years experience designing and architecting primarily web based applications. Fresh out of college during the nineties he co-founded Task Solutions and developed several projects with the then popular classic ASP.
During the Dot Com boom Kevin left his position as president and joined a new venture to build an enterprise insurance claim system build upon J2EE technology. After the Dot Com crash Kevin schooled himself to become an expert with .NET technology and is currently freelancing his ASP.NET skills to build enterprise n-tier frameworks using advanced OO methodologies.