« March 2006 | Main | May 2006 »

April 25, 2006

Talk about good design

My blog has moved. Please go to: http://jstawski.com/archive/2006/04/25/Talk-about-good-design.aspx

Well, well, well, where do I start? I'm recreating this stored procedure for a client and I'm listing all columns I need from a table. What do I see? Something I thought I would never see in my life. The table contained a list of about 14 flags that specified something to be on or off. To be more specific, the columns looked like this: flag1_on, flag1_off, flag2_on, flag2_off and on and on it goes with a total of 7 flags * 2 (1 for off and other for on). I look at the data and I see that when flag1_on is 1 then flag2_off is always 0.

What is the correct design for this table? Well if you have a defined numbers of flags it is ok to have them layed out as columns of the table, but the columns should be flag1, flag2, flag3, etc of type bit. Why bit? Because the bit type holds a value of either 0 or 1; on or off. This gives you 3 possible choices: flag not set (null value), on, or off. If you need only 2 values then you don't allow nulls in the column and specify a default value [optional]. You might ask yourself why not use a char(1), varchar(1), nchar(1), nvarchar(1), or integer for that matter. The answer is very simple: the bit type is the smallest of them all and allows only a 0 or 1, while a char or varchar might allow other characters such as ‘A’, ‘X’, ‘4’, ‘$’, etc and adding inconsistency to the data.

If the number of flags is undefined because they are dynamic then a different approach is taken. You have the parent table with a many-to-many relationship to this newly created table that holds the name of the flag and whether the flag is on or off. In this case the flags are displayed as rows rather than columns.

Happy Programming!

12:28 PM | Permalink | Comments (0)

April 21, 2006

Alabama Code Camp

My blog has moved. Please go to: http://jstawski.com/archive/2006/04/21/Alabama-Code-Camp.aspx

Hello everyone. Please join me Saturday 22nd of April in Alabama for the Alabama Code Camp. If you missed my pervious presentations this will be a good opportunity to attend to them. I'm presenting two sessions N-Tier Application Architecture and Ajax.

And don't forget... Happy Programming!

08:06 AM | Permalink | Comments (0)

April 17, 2006

Spanish Language Pack for DotNetNuke (DNN)

My blog has moved. Please go to: http://jstawski.com/archive/2006/04/17/Spanish-Language-Pack-for-DotNetNuke-_2800_DNN_2900_.aspx

Hi everyone! I was in need for a language pack for the es-AR culture (Spanish - Argentina). I couldn't find one, but I did find the es-UY culture (Spanish - Uruguay). The author did an incredible job on translating everything. Both cultures and languages from Uruguay and Argentina are almost identical so I grabbed his Language Pack, created a small app that renamed all the files with es-UY in it to es-AR, and zipped it up. I then uploaded it to my DNN website and worked like a charm. I sent it to the DNN fellas. Here's the link to the DNN Laguage Packs: http://www.dotnetnuke.com/Default.aspx?tabid=785&action=cat

Note: As of the time of this posting, the Language Pack was not uploaded to the DNN website.

As always: Happy Programming!

01:54 PM | Permalink | Comments (3)

April 06, 2006

GridView, HyperLinkField, and JavaScript: what the #%$@!

My blog has moved. Please go to: http://jstawski.com/archive/2006/04/06/GridView_2C00_-HyperLinkField_2C00_-and-JavaScript_3A00_-what-the-_23002500240040002100_.aspx

When you always think something is going to go very smooth you know there will be something to make it rough. Of course I'm talking about code. As the title might have given it away, I'm talking about the GridView. To be more specific: a GridView with a HyperLinkField and JavaScript.
In 2005, a HyperlinkField cannot have javascript. For some reason if you do something like this:

<asp:HyperLinkField HeaderText="PLAN IMG" DataTextField="PLAN_IMG" Text="{0}" SortExpression="PLAN_IMG" DataNavigateUrlFields="PLAN_IMG" DataNavigateUrlFormatString="javascript:MM_openBrWindow('../images/elevations/{0}','img','');"/>

The grid will be rendered without a hyperlink. How to solve this problem, you may ask. After reading this blog I came up with a solution. Use a BoundField with a dataformatstring of an anchor.

<asp:BoundField DataFormatString="<a href=javascript:MM_openBrWindow('../images/elevations/{0}','img','');>{0}</a>" DataField="PLAN_IMG" HeaderText="PLAN_IMG" SortExpression="PLAN_IMG" />

Please note that I don't have any spaces in the href=. Hope this helps you guys.

Happy Programming!

02:51 PM | Permalink | Comments (31)