5.25.2004

Binding a DataGrid to an arraylist of strings

...or any simple value type for that matter.

A friend of mine asked me this question and of course it sounds simple. All he wanted to do was:
<asp:Datagrid id="grid" runat="server">
<Columns>
<asp:BoundColumn DataField="..."/>
</Columns>
</asp:Datagrid>

The question was what to put as the DataField, since he's binding an arraylist of strings, as in:

ArrayList list = new ArrayList();
list.Add("1");
list.Add("2");
list.Add("3");
grid.DataSource = list;
grid.DataBind();

What indeed? There's no property on the string data type that returns the string. Doing a little google searching didn't turn up anything satisfactory. One idea was to wrap up the array list into a hashtable (where you can use Key/Value), or to make a custom class and bind that. Yuck, thats a hack! It isn't reusable at all -- and most importantly, it might be a designer messing with the aspx (or ascx) page, and they can't and shouldn't have to write code to accomplish the task. Here's what I would consider the "right" way, which requires zero code changes:

<asp:Datagrid id="grid" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>
<asp:TemplateColumn>
</Columns>
</asp:Datagrid>

5.22.2004

Power-napping

That mid-day dip in alertness really grabs hold of me sometimes. Sure, staying up researching longhorn until 1:30 the night before doesn't help. Neither does getting up before the sun rises (an evilness in today's world). But that mid-day dip still seems unnaturally strong. The interesting thing is it's always around 2pm at its worst... if I manage to fight through it, by 3pm I'm back up to normal, and as chip as ever. I know what you're thinking -- its the lunch! Yah I've heard that before but I don't believe it. It doesn't matter when or what I have to eat. Even if I eat nothing.

What's the deal??? Is there something in the air conditioning ducts? It's as if the human body was meant to take a nice little siesta in the middle of the day.

As far as I can tell via google that's a generally accepted idea, and many studies have shown that a 15-20 minute "powernap" once or twice a day can increase overall alertness. Say what?? Where was this study when some genious invented the 8 hour work day? <yawn>... good night.

Hello World

This will be a place for my thoughts. Thoughts about the world, the universe, philosophy, yadda yadda yadda. They'll be wierd, sometimes they won't make any sense, sometimes they will be completely wrong. That's cool though... at least I've got a place to put them. Maybe someone out there will stumble upon my little island of thoughts here, probably through some completely unrelated google search, like "popcorn and fish" or "what is iodized salt", or what-have-you.

If you do happen upon this blog, be sure to drop me a comment or two... I promise I won't delete it.