Tuesday, April 15, 2008

How to examine if the datagrid item created is the header item

Code example in the ItemDataBound event handler:

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Header)
{
//This row is the header of the grid.
//Add code to do whatever you want to the header

}

}

Sunday, February 17, 2008

MSSQL: The backup set holds a backup of a database other than the existing database.

When restoring a backup database that itself has a backup database, you will get this error:
"The backup set holds a backup of a database other than the existing '<DBName>' database."

All you need to do is to select the "Option" screen and make sure you have "overwrite existing database" selected.

Saturday, February 16, 2008

C# .NET: Get current dirctory of the executing process

System.Environment.CurrentDirectory doesn't always give you the current directory of the process. For windows service, it gives you C:\windows\system32.

Use:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);