Archive for August, 2010

Generic List.Sort

30 August, 2010 Leave a comment

I often want to use a list to sort and every time I have to go searching on how to use the IComparer interface.

Assume I have a Person object with the “DisplayName” property that I wish to sort by.

I created the following class:

public class PersonDisplayNameAscendingComparer : IComparer

#region IComparer Members

public int Compare(Person x, Person y)
return x.DisplayName.CompareTo(y.DisplayName);


And then assuming you have a List called people, you can sort like this;

PersonDisplayNameAscendingComparer personComparer = new PersonDisplayNameAscendingComparer();

Job done.

Categories: c#

ASP.Net Membership Provider – Install Database

30 August, 2010 Leave a comment

In the membership provider model is a cool way of easily getting a security datamodel with role access.

The database can be installed on your own specific database in the following way.

Some architecture based sugestions:
1. The membership provider model is actually keyed by application. So you can provide user lists for multiple applications from a single database. This means that instead of creating the model inside you application database you can store this in a central applicaiton security database and provide a single database that manages users for all of your applications.

1. Ensure you have SQL server installed on your system. This could be SQL Server Express.

1. Open a command window.
2. cd to the following directory [drive:]\%windir%\Microsoft.NET\Framework\version
3. run aspnet_regsql.exe ( by default this will run in the Wizard Mode)

In the wizard:
1. Click Next
2. Choose “Configure sql server for application services” and click next
3. Select the Server and Database set your database connection details (note change to \sqlExpress named instance)
4. Choose Next Next Finish

Your database has now been created and is ready to be used.

Categories: ASP .Net

SSRS 2008 R2 – Name Tabs when exporting Reporting Services Report to Excel

5 August, 2010 5 comments

This is a long sought after and requested feature, and finally in 2008 R2 it’s here.

The property that you are looking to set is:


Set this and then on export to excel the tab will use the page name.
This can be set on certain objects in the report and can use Expressions to set the name.
Objects that contain this property include:

  • Tablix
  • Rectangle

As an example of how it works, I have a report that runs as 2 sub reports. Each subreport has a tablix that has the page name property set.
When the report exports to excel I get 2 tabs each named as defined in the page name property.

Another more complex example is using a tablix with grouping. Set the tablix to page break on the element that you are grouping by and then set that element as the value for your page name. Each time the grouping changes it will render in a new page and if exported to excel each tab will appear with the name of the group.

This post goes into it in more detail


Categories: Reporting Services