Friday, June 22, 2012

ASP.NET: DropDownList throws an exception “[ctlName] has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value”

 

Yes, you may monitor this exception if your DropDownList WebControl is initialized programmatically, like

ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is exception thrown

If the data source doesn’t include an element with empty string as value, the above mentioned exception is thrown.

The problem is solved with setting SelectedValue of the DropDownList to null:

ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.SelectedValue = null; // <- added to solve
 

                                       // the problem
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is no more exception

Enjoy!

Thursday, June 07, 2012

Windows Server 2012 for download

Yes, the WS12 is here: http://technet.microsoft.com/en-us/evalcenter/hh670538.aspx

Registration required. You can download the .ISO (localized in many languages) or .VHD to bind under Hyper-V

image

The VHD is an exe-archive (~3GB to download), ~8GB extracted.

The administration password will be set on the first start.

I’ve got it running having 3GB RAM.

Download and enjoy!