August 2009 Entries

Quick Tip: Check DataKeyNames in ListView If Events are Failing

Just a quick tip this morning. I have a TimeSheet program I wrote that I recently overhauled with new controls and databinding, etc. I have a ListView in it that displays all my time records in a paged format, and also allows me to delete entries. However, whenever I clicked “delete”, the page would just postback to itself and nothing would change. There were no exceptions or anything, so it was a bit of a head scratcher. I had this problem once before a long time back, and it turned out that my ......

Quick Tip: Cast DataItem in ListView to Business Object

So this is one of those things that has slipped past me for all these months and now that I’ve discovered it, I can’t believe I went without it. I recently found out that I can access a business object in the ItemDataBound event of a ListView which makes it way easier to do some last minute control changing (such as binding labels or hyperlinks, etc.) In my example, I have a LINQ to SQL class called Question. My ListView hooks up to a datasource of IEnumerable<Question> and displays its properties—nothing ......

“Value cannot be null. Parameter name: container”

So I came across this fun error today, which stopped me from being productive for about 2 hours. Unfortunately my search on the internets did not prove to be useful, so I had to manually dig through every part of my code to understand what was going wrong. Seriously, could the error be less generic? The stack trace indicated that the error was coming from the ListView databinding—which was of some help ,but not much, since the page I was getting the error on has about 10 listviews (It’s a portal ......

“Keyset does not exist” Health Vault Application Error with IIS

I was working this morning on hooking up the application I’ve been writing to Health Vault, and I came upon this fun little error “keyset does not exist” that is everywhere on bing and google.com but lacking any clear instructions on how to fix it. After about two hours of trying to figure out what exactly was going on, I finally have my application working. For both the purposes of helping others fix this error, and for me to remember what I did when I try to set up an application on our live server, ......

Modal Confirm Dialog Server Control

My general rule of thumb (which I actually read on some other site or blog, or maybe in a book or on the msdn?) is that if you plan on using a control once or twice, use a web user control. If, however, you want to use it all over your program, you should invest the time to make it a server control. They are much easier to use in the program (in the long-term), since they allow you to drag and drop them from the toolbox and you can pass them between programs easier as a DLL instead of a .ascx file. ......