Wednesday, January 14, 2009

Poor network performance on Microsoft Hyper-V

I recently installed a Windows Server 2008 with Hyper-V to host my Virtual Machines. As overall performance seemed to be better than on Virtual Server 2005, I ran into very poor performance when copying files between the Guest and Host using a file share.

I tried several solutions I’ve found on the net, but in the end, I found that one should NOT use the ‘Legacy Network Adapter’ in Hyper-V but use the ‘Network Adapter’ when adding a network card to the VM.

When copying a 4GB (iso) from the VM to a (shared) USB drive attached to the Server, the speed went from barely 2MB/s to a reasonable 17MB/s.

Friday, December 19, 2008

“Value cannot be null” error on postback when using Grouping in SPGridView

When you use an SPGridview with grouping enabled, you will receive an exception whenever you perform a postback: Value cannot be null. Parameter name: container.

Patrick Rodgers came up with a solution which you can read here: http://www.thesug.org/blogs/patrickr/Lists/Posts/Post.aspx?ID=2

The solution is to create your own GridView that inherits from SPGridView and override LoadControlState to raise an event whenever the DataSource is null. The page or control that implement the GridView will need to implement an eventhandler and make sure the Grid is bound to it’s datasource.

Friday, November 28, 2008

Microsoft.SharePoint.WebControls.DateTimeControl ignores regional settings

When you use an instance of the Microsoft.SharePoint.WebControls.DateTimeControl in SharePoint (for example in a webpart), the locale will always be set to en-US, even if the web of user have specified a different locale.

To overcome this, you need to explicitly set the LocaleId property of the control to the correct locale.

DateTimeControl dtCtrl =new DateTimeControl();
dtCtrl.ID = "dtCtrl";
dtCtrl.LocaleId = (int)SPContext.Current.RegionalSettings.LocaleId;
this.Controls.Add(dtCtrl);


You should use SPContext.Current.RegionalSettings as this reflects the RegionalSettings for the current user (they might differ from the Web if the user modified this).

Wednesday, November 19, 2008

Sharepoint lookup with picker

Microsoft Sharepoint Server 2007 lookup control with element picker for custom list.
This control is useful if you need to choose lookup data from large lists. This control supports single and multi select mode.

http://www.codeplex.com/lookupwithpicker

Sunday, November 16, 2008

‘Title’ field and property not available on SPItem when using a View to access the SPListItemCollection

You can get an SPListItemCollection from a List using a View with the following code:

SPList list = SPContext.Current.Web.Lists["My List"];

SPListItemCollection items = list.GetItems(list.Views["All Items"]);

When then try to access the Title field of any of the individual SPListItem instances in the collection you will receive an ArgumentExecption


//all these statements will throw an Argument Exception
string titleField = item[0]["Title"];
string titleProperty = items[0].Title;
string titleValue = items[0].GetFormattedValue("Title");

As a workaround, you can access the Title field value using the LinkTitle field:


//this will return the correct value
string title = items[0].GetFormattedValue("LinkTitle");