Formatting data in databound controls

Posted by andy gaskell on Apr 18th, 2006

I’ve been trying to format DateTime and currency in asp.net 2.0 databound controls (DetailsView and GridView). After some googling I was able to get it figured out.

To format DateTime values, you might expect to use a tag like this:

<asp:BoundField
     DataField="BeginDate"
     DataFormatString="{0:d}"
     HeaderText="Begin Date" />

and have a result like this:
10/10/2004

but instead you get a result like this:
10/10/2004 12:00:00 AM

Here’s the fix - add HtmlEncode=”false” to your BoundField tag:

<asp:BoundField
     DataField="BeginDate"
     HtmlEncode="false"
     DataFormatString="{0:d}"
     HeaderText="Begin Date" />

The same idea applies to formatting currency, I’m assuming other types of data formatting as well. Here’s Microsoft’s explanation.

Technorati Tags: , , , ,

How to remove Comcast branding from Internet Explorer

Posted by andy gaskell on Apr 14th, 2006

I just switched over to Comcast’s 8 meg connection - wewt! Anyway, I wasn’t too happy with their software branding IE and resetting my homepage.

Here’s how to remove the branding:

Click Start, then Run… type

Rundll32 iedkcs32.dll,Clear

exactly as shown. Click OK.

Another great idea is installing Firefox - the download is small and it’s a very nice, secure web browser. Click the link below to learn more about Firefox.


A couple of signs your database design is suspect

Posted by andy gaskell on Apr 11th, 2006

A few warnings that you might be in over your head:

Sixty-six percent or more of your columns for a particular table are primary keys.
If you have more than oh, say, 20 columns in a single table, put some serious thought into why you’re doing that.
You have a table named BAD_MAIN.
You start to create new BAD_MAIN tables monthly.
Ok, BAD_MAIN might not be so bad, I just find it funny.
evrytg is abrvd so u dnt hv 2 typ (or ndrstnd) as mch - ALLTMT_PRD_MO_NBR. Seriously.

Next »