Love hate relationship with Asp:DropDownList.AppendDataBoundItems

Here's the deal.
I want to bind the dropdownlist to a List<Blob>.
But I want the dropdownlist to have an initial empty field.

Most people do this:

<asp:DropDownList ... EnableViewState="true" AppendDataBoundItems="true">
    <asp:ListItem Text="" Value="" />
</asp:DropDownList>

Which is nice and dandy, until you need to update the datasource of the dropdownlist.

AppendDataBoundItems will make sure all the current items stays in the list, and all the ones in the new datasource gets added to the list.

So you ended up writing silly code that looks like this:

string selectedValue = dropdownlist.SelectedValue;
dropdownlist.Items.Clear();
dropdownlist.Items.Add(new ListItem());
dropdownlist.DataSource= List<Blob>;
dropdownlist.DataBind();
dropdownlist.selectedValue = selectedValue;

 

I promise my next code rant will look a lot better than this rubbish!

An interesting quit smoking help

A colleague mentioned a site quitext.com which is a quit smoking support website.  They send you daily SMS' to help encourage you to quit smoking.  You can also buy it as a gift for someone you know.

I don't think I'll ever smoke myself, but I can understand wanting to quit smoking can be very difficult at times.  It's good to have different ways to help out.

MIX08

Everybody is blogging about it.  I'm not there, but still the amount of betas rolling out from Microsoft is making me very happy.

  • ASP.NET MVP beta 2
  • IE8 beta
  • Silverlight 2 beta 1
  • Expression 2.5

Colleague forwarded a news article to me where Microsoft is partnering up with Nokia to deliver Silverlight on the Symbian platform.  So that's going to make this platform very tidy.

Good times.

Watching news

Giving up caring about the US Election.  Being following the US Election, and sadly I stopped caring when Ohio and Taxes voted for Hillary Clinton.  With the democrats continuing their in-fighting while the republicans relied behind one nominee, I just can't see the government switching to the democrats.

Great job, please continue to help the other party by destroying each other's credentials.

New words

Went to a mandatory AGILE methodology meeting session currently being pushed by the client.  Personally I consider myself already sold on Agile methodologies, so feels somewhat that it was going to be a gigantic waste of time.  But it was mandatory, so to keep everyone happy, I went.

I went with a notebook, and just moments before the session, I had a brilliant idea of noting down any new words I'm about to learn that day:

spike-solution

We call it a deep-slice, but it's slightly different.  A spike solution is a focused technical effort to explore whether a technical design is actually possible or feasible.  In the particular Agile session it seems the spike solution is also a throw-away solution.  But I can see it being documented on a dev-wiki until it's used in implementation.

A spike-solution is good because it reduces risk - if an approach can not work, it is better to know early rather than later (say, after all the UI, database, etc have been designed).

re-engineering

It's like re-factoring, but not re-factoring.  It's re-engineering.  You can't engineer a business process, because it's business and not engineering.  But you can re-engineer a business process (I guess by applying engineering processes to a business procedure).

I consider this word a "rubbish word thrown-in to confuse people".