Having different scope for your property

C# 2.0 gave us this:

private string _property;
public string Property
{
    get { return _property; }
    private set { _property = value; }
}

C# 3.0 gave us this:

public string Property
{
    get;
    private set;
}

Due to the rules of encapsulation, the accessor/getter usually has a more relaxed scope than the mutator/setter.

I've recently came across cases where the tables are turned.  Hurray for some dependency-injectioness!

[CreateNew]
IService MyService
{
   private get;
   internal set;
}

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.