This is not the SelectedValue you're looking for

Oh, here's a fun one.

I have a list of locations that I'm retrieving from a web service, and I want to display them in a ComboBox. I also want to have a blank entry at the top of the list, so "nothing" can be selected. While I'm sure there are ways to do this with less code, creating binding objects and such (especially since the retrieved object list is already pre-sorted in the order I want), I've resorted to just creating a DataTable with an ID and display column and copying the values I want into it. It does make things easier when I have one combo box filter another, as DataTables already have code written for searching and filtering.

Anyway, after I get my data, I have a DataTable that looks like this:

7Colorado Springs
3Ft. Collins

Now, I bind it to my ComboBox like this:

combo1.DataSource = dataTable;
combo1.DisplayMember = "Location";
combo1.ValueMember = "LocationId";

Note that you have to set the DataSource first and the DisplayMember & ValueMember properties second, otherwise you get a ComboBox full of "System.Data.DataRow". Nice.

Now, on this form, when a value is selected, the selected value is used to filter another list; and, when the form is submitted, the selected value is passed off to a web service. How do you find out when a value is selected, and what that value is? Simple; bind to the SelectedValueChanged event, and query the SelectedValue property, right? In theory.

In practice, no. To make a long story short, I dropped a label onto the form so I could see what was going on in "real time". First, the code:

private void combo1_SelectedValueChanged(object sender, EventArgs e) {
     label1.Text = Convert.ToString(combo1.SelectedValue) + " - " + Convert.ToString(((System.Data.DataRowView)(combo1.SelectedItem))["LocationId"]);

And the results:

ComboBox selectionLabel1.Text
empty - 
Aurora1 - 2
Colorado Springs2 - 7
Denver3 - 1
Ft. Collins4 - 3
Longmont6 - 4
Parker7 - 6

Incidentally, the SelectedText property was always blank.

On the up-side, as you can see, I found a way to get the real value (using the SelectedItem and casting appropriately). On the down-side, it means I have to use that construction to get the selected value on this and every other similar ComboBox (there are actually four on this form alone), since SelectedValue, apparently, doesn't.


You have... zero... messages.

As I was attempting to pay my T-Mobile bill this past weekend (a futile endeavor, as their billing system was unavailable — an unfortunately very common occurrence), I decided to look at their offered services. It was mostly just morbid curiosity rather than actual interest, as I find cell phone rates for services obnoxious.

I've ranted about the ridiculousness of text messaging prices before. (As a side note, I have noticed that it does seem that I am not charged for a text message receipt when one is sent to me, but only when I choose to read it. It's still not terribly comforting, considering my phone has a tendency to double-tap the "OK" key, so my attempt to view my message list often inadvertently results in my reading a message, whether I wanted it or not.)

One thing that annoyed me was the fact that text messaging plans were specific to phone lines, not to plans. My wife and I have a phone plan where we share minutes; but we cannot get a plan that allows us to share messages. Well, T-Mobile has added a family messaging plan that — lo and behold — allows you to pay once for messaging on all lines on your account! Unfortunately, the only plan available for an entire family is the "unlimited" plan, which is $25/month. It's still way above and beyond expensive for our usage (which is more like 10 messages per month), but I'll bet for some families, this would be quite a deal.

Another major annoyance I had was that there was no way to block text messages. You couldn't stop someone from sending you messages to potentially run up your phone bill. Well, that, too, is no longer a problem. There are now options for blocking messages, either per-phone or for the entire plan. There are various options for blocking, too, limiting outbound messages only, or limiting inbound messages to those from other phones (i.e. no automated spammers), or blocking all inbound and outbound messages completely. And best of all, all of the options are free!

Needless to say, I turned on all message blocking. As long as they insist on charging per text-only, length-limited email message, I won't be using it.

And while this may come as a disappointment to the two people who actually send me text messages from time to time (which I don't read, and either keep forgetting I don't read them or keep forgetting to remove me from whatever distribution lists they have that I'm in), I can only say: just send me an email. Or call. That's what a phone is for. :P


The $2 Electric Razor

I've used an electric razor ever since I first started shaving. They're quick, they're easy, and they're safe, especially compared to the standard blade. But where I did use a rechargeable before, I've since gone to just using a plug-in. The problem I had with rechargeables was, whether I left them plugged in all the time or ran them down and "deep cycled" them, it seemed like the batteries would consistently stop holding a charge before the blades would get dull.

The interesting thing about replacing blades, though, is that I never actually do it. I've found that the price for new blades is so expensive, and the price for a simple, plug-in electric razor is so cheap (because only the cheapest models are plug-in; the first feature that gets added as the price goes up is cordlessness), that it's just as cheap and twice as easy to buy a whole new razor than it is to find a set of blades that's compatible with the razor I already own.

Case in point: my last Norelco razor stopped cutting as well as it should. I went down to Wal-Mart to look at razors. Razor blade heads were $29 (and since I didn't know the model number of my razor off the top of my head, I wouldn't know which one to get, if a compatible set was there at all), and a new Panasonic razor was $31. Which leads to the inescapable conclusion that the razor itself — the housing, the motor, and even the flip-up trimmer and the blades contained therein — are worth a grand total of two dollars.

Which sounds about right, considering the flip-up trimmer on my old Norelco had also broken, being driven by a cheap piece of plastic. Buying new heads wouldn't fix that.


Bandwidth for June

June was also a fairly light month. Total downloaded was 18.49GB, total up was 6.28GB, for a grand total of 24.77GB.

I got the Xbox 360 game Ghostbusters for Father's Day, and I was very close to activating a Netflix trial so I could stream the original movie — which would have been very educational as far as bandwidth consumption is concerned. However, that very next day, my Xbox died and had to be sent in for repairs, so that killed those plans.