Richard Howells' Blog
Author: RichardHowells Created: 11 March 2008
Notes about the interesting (my definition) bits I discover in my programming. Plus, of course, the occasional tar pit.

I just tried setting up a staging version of a site.  I used _Staging as a suffix everywhere.  I found that IE would not let me login. (It worked with Chrome.)

I changed the url to use instead of the suffix and the problem went away!

My network (largely Windows 7 machines) partly stopped working, from my laptop.  Explorer would not browse to other machines, the network always showed empty.  OTOH I could map drives by IP address and I could ping them cheerfully.

Other machines seemed unaffected - it was just me.

Hours of Googling got me nowhere.

Yesterday I just lucked onto it.  On my laptop, the windows firewall thought my home network should be treated as public.  Setting it back to a private network seems to have fixed all my woes.

Yahay! :-)

A – Because the browser does not work the way you think it should.  When you press F5 the browser requests the resource it is currently on AND resources directly linked to that page – images.  I set up a web site to serve images with an expiry time.  The idea is that most of the graphics in the skin change rarely.  The browser does not need to down load a fresh copy for each request.

Fired up fiddler, pressed F5 a few times and got stumped.  Every time the browser was making a fresh request for each image.  When I moved to requesting the page via a link, even a link on the same page, I saw the cache work as I expected and the requests vanished.


 Add this (or similar) to the URL

"?SkinSrc=Portals/_default/Skins/MinimalExtropy/index full"

I posted this so that I would be able to find it easily for myself.  You can do somthing similar with ContainerSrc too.

Shows how to create a set of hierarchical check boxes.  Checking/unchecking a box at the higher level automatically checks/unchecks the ones at the next level down.

Read More »

I wanted a very simple logging table. I wanted it to be time ordered and I decided to include a smalldatetime column in the primary key.

This failed badly with Entity Framework. Inserts resulted in a failure message indicating that zero rows were affected. This because a .Net DateTime value is not guaranteed to round trip into SqlServer and back. The SqlServer datetime (and smalldatetime) column types cannot store values with the same precision as the .Net DateTime type.

EF uses a query like this [1] to store the row and recover the freshly inserted identity column. The DateTime value is ‘rounded’ to suit SQL Server as it is inserted and the Select fails to read the freshly inserted row back because the datetime values are no longer equal.

I solved this by removing the datetime column from the primary key. It was not crucial for it to be in the primary key.

Moral – do not mix datetime and identity columns in your primary key.

[1] Entity Framework Generated Query exec sp_executesql...
Read More »

 You need all these MIME types.  Most of them are probably inherited from higher up but I needed to add a couple - could have been a version thing!


I found this StackOverflow question useful

 If you came on the 327 course (C++) I taught at Learning Tree week of 16Feb and have been waiting for your follow up email please accept my apologies.

Somehow I lost the pile of papers with your email addresses and I have no way of contacting any of you.  Send me an email address and I'll send you the promised material.

Just one way a 30 minutes job can take 5 hours.

Read More »

DataGridView – how to show a subset in a DropDownColumn

The standard approach is to add event handlers for CellBeginEdit and CellEndEdit. In CellBeginEdit a new datasources is bound to the dropdown and in CellEndEdit the binding is reversed. Here is a sample from the DataGridVew FAQ.

private void dataGridView1_CellBeginEdit(object sender,         DataGridViewCellCancelEventArgs e)


if (e.ColumnIndex == territoryComboBoxColumn.Index)


// Set the combobox cell datasource to the filtered BindingSource

DataGridViewComboBoxCell dgcb = (DataGridViewComboBoxCell)dataGridView1                        [e.ColumnIndex, e.RowIndex];

dgcb.DataSource = filteredTerritoriesBS;


// Filter the BindingSource based upon the region selected

this.filteredTerritoriesBS.Filter = "RegionID = " +

this.dataGridView1[e.ColumnIndex - 1, e.RowIndex].Value.ToString();




Read More »

Copyright 2002-15 by Dynamisys Ltd