How to include a header on each page when printing a DataGrid - The Code Project - .NET

There is a simple solution for printing tables with repeating headers on each printed page. It involves CSS styling of the THEAD section of a table. Unfortunately, neither DataGrids nor GridViews render the THEAD tag. Somehow, Microsoft seems hellbent against it. So either create a control that renders THEAD, then add "display:table-header-group;" to the THEAD style, or use this Javascript function:



function AddTHEAD(tableName)
{
var table = document.getElementById(tableName);
if(table != null)
{
var head = document.createElement("THEAD");
head.style.display = "table-header-group";
head.appendChild(table.rows[0]);
table.insertBefore(head, table.childNodes[0]);
}
}
Update:
Building a GridView, DataGrid or Table with THEAD, TBODY or TFOOT sections in NET 2.0

Using SQL Server instead of Access files:
1. Run aspnet_regsql.exe (from the NET Framework 2.0 folder)
2. Add to web.config (inside the configuration tag):
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
(that's because LocalSqlServer is already defined by default. Really dumb)
3. Go to the Website menu in Visual Studio -> ASP.NET Configuration and create users, roles and access rules.

Logging out programatically:
FormsAuthentication.SignOut();

Changing settings for the membership (in system.web section):
<membership defaultProvider="CustomizedProvider">
<providers>
<remove name="AspNetSqlMembershipProvider"/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
commentTimeout=""/>
</providers>
</membership>

and has 0 comments
Gibson arrest 'handled correctly'

This is a rant marginally related to the Holocaust sucks post. Let me first say that I am NOT against the jewish people, even if I strongly think the Israeli external policy is a dark shameful spot on the face of humanity in general.

There are some words or attitudes that are socially not cool, politically incorrect, or whatever you want to call them. For example talking about fascists or terrorists as bad people is good. Talking about Jews as bad people is not good. Using 'nigger' when you're white is not good, but as a black man it's completely ok. I wonder if it's ok to say it if you're Asian. Of course, this is all bullcrap. People have the right to say what they think and not be persecuted by it. Eventually, if a behaviour is determined by society to be wrong, then it should be punished or looked down upon in ALL its manifestations.
My main focus today will be antisemitism. First of all, the very word annoys the hell out of me, Semites are Jews as well as Arabs and some other nationalities. To hijack the term to mean almost exclusively racism against Jews is discriminating in itself. Second of all, there is no need for a special word that describes racism against a single race or group of races. We've determined that racism is bad and that antisemitism is racism, so why use two words? Is it because, somehow, idiots think hating Jews is worst than hating Romanians, for example? And third of all, have you noticed that the most "opressed" of nationalities usually have a strong xenophobic culture, almost always having a special word for people that are not like them? The Jews have Goim, which means People and also Body. They very rarely use it in relationship with jewish people and most of the time only to refer to non-Jews. They also have specific other words that mean non-Jewish. They don't use kind words about Goim either. But I guess that's not racism, because they actually look down upon all races equally, except their own. In a way, they discriminate themselves, right?
So my solution is this: let us consider any racist remark a bad thing, while in the same time consider idiotic and not worth any attention any phrase or argument that contains "antisemitic". That would solve it, right?

Scripting Center
Download details: Scriptomatic 2.0

WMI or Windows Management Instrumentation is Windows service who's basic function if to get information from a computer (even remote ones), but that has been upgraded to be able to also put information or run stuff. Weird little things like the manufacturer of the sound card or information about installed and running programs can be extracted with WMI, but also reading from a database or automate Sysadmin tasks for all the computers in the network, etc.

Well, this blog entry is not supposed to explain what WMI is, but to introduce the Microsoft Scripting Center. The link is above, it shows you how you can access and display/modify, etc information with WMI using scripts. The tool Scriptomatic 2.0 (download link above) automatically creates scripts in vbs, js, python and perl to list information in any of the WMI classes. The Scripting Center has a lot of scripts, categorised, so that you can download them and use them directly or with little modification, also tutorials and other useful links. Check it out!

I had problems with WindowsFormsParkingWindow and a lot of the references on the web pointed to this blog article. Unfortunately, the page was not available when I started searching for it. The only place I could find it was google cache, god bless their big googly hearts :) Therefore I am reprinting the content here, maybe it helps people:

=== WindowsFormsParkingWindow a.k.a The devil ===

I have been working on an application for a few weeks and suddenly it started freezing up for no reason. After copious amounts of swearing and breaking keyboards I found a hidden window in the windows task list. It was called - WindowsFormsParkingWindow. My new worst nightmare.

Nothing seemed to stop this issue from killing my program. After more swearing and cursing I found that this error happened after ALT-Tabbing away from my app and back into it. The parking window would appear and my app would die. I ran WinSpy++ and made the hidden window visible. Behold the glory of the following...

The hidden window contained a user control that I had previously removed off the form. This might not make sense to you now but let me explain the significance. When you remove a control from a form/panel, it gets put onto a WindowsFormsParkingWindow until you put it back onto the panel/form. So the WindowsFormsParkingWindow is kind of like an intermediate place windows keeps user controls before they are put into containers.

You might ask now - "What has that got to do with my app freezing?" Well, I'll tell you exactly why... Because when you remove a control from a panel/form and it has focus, the focus stays on the control (which is now on an invisible form). That's why events fail to fire and the app becomes unresponsive.

The solution? Easy...

Instead of using pnlParent.Clear() or just removing the control you need to do the following:

1. Remove the focus from the current user control by setting it to the parent form.
2. Remove the desired user control by using the ParentControl.RemoveAt( indexOfUsercontrol )

This should clear up the issue.

Just now I watched a little youtube.com video that explained the two slit experiment. Basically, what happends is that a pattern emerges if you use waves and another when you use particles. Then you fire electrons in the thing, and wave patterns emerge, even if you fire one electron at a time, therefore the single electron is interfering with itself! But even stranger, when you put an observer to see what slit the electron goes through, the pattern changes into a particle pattern. This proves that observation changes what we observe.

Wait a minute! But isn't science supposed to be based on observation? This very experiment has been observed, for crying out loud. So what does it mean? If you demonstrate something by scientific experimentation, therefore using observation, doesn't that mean you only demonstrate what happends when you look at something, rather than what that something is? Since the same experiment has been observed using eyes and it behaved differently when they use a finer tool, then it means the type of observer alters the result. Would things start behaving differently if an alien was to come on Earth? This is mind boggling.

Links:
YouTube video -< it was removed from YouTube
Another YouTube video
Wikipedia on the double slit experiment
Cool java applet on wave interference

and has 3 comments
Do you know how some games have so much publicity spin on them and so much advertising that they immediately start making money and becoming "the most popular game"? Arx Fatalis is not one of those. This game is a rediscovery of the good old values of Ultima Underworld: good story, great playability, nice AI, very little or no getting stuck possibilities, fantastic immersion in another world. If you loved Ultima Underworld (which can be found free on the net, but I am not sure you can make it work on the newest computers around), you will definitely fall in love with Arx Fatalis. I am telling you, I am hooked. I finished the game in a working week and two weekends and I did it so fast because my wife wanted me to give some attention to her. Yes, you read right, Arx Fatalis IS better than sex.

You can get it very cheaply from Good Old Games.

Ok, what is so great about it? I will give a few hints and let you discover the rest for yourselves:
  • you make magic by mouse gestures (you move the mouse in certain patterns, like in Black and White)
  • the AI characters yell for help from associated NPCs and run away when too hurt
  • I once ran into an impenetrable beast that could kill me with one touch. Running away from it I reached a dead end. I expected to find no way out, but the beast disappeared and reappeared a few feet behind, just enough to let me run away.
  • I couldn't find ONE spot where I would have gotten stuck in the entire game.
  • the quests are intelligent. You need to use brains to finish this one. It's not something that must be searched on google to finish, either. If you have the will, there is a way.
  • you can kill almost every character in the game as well as finish their quests.
  • a lot of side quests. You can finish the game in a week or in a few months, it depends on you.
  • hidden magic spells. Each rune has a specific meaning. Try combining them in innovative ways.
Not interested yet? Oh, come on!

Update: I have found a Doom3 mod that tries to be a prequel to Arx Fatalis. A pretty neat effort and I am glad I found a new reason to upgrade my computer :). This is their site: Arx – End Of Sun and this is a gameplay video: Arx - End of Sun (Gameplay Video #1) [Doom 3 SP Mod].

and has 0 comments
Mark's Sysinternals Blog

I hope this is something Microsoft did in order to improve their products, but I fear that the only reason for this purchase is to shut down the sites that give for free better tools than the one Microsoft puts in their OS. If this happends, I'll just move to Cygwin and ports from Linux for system tools X(

and has 0 comments
Nowadays Indigo seems to be a classy name. Everything is Indigo, from WCF to skins for every possible program or device. The new beta for Yahoo Messenger comes with the classic skin (aka Old Windows Forms style), Indigo (something that looks like Windows XP) and Maverick. Even if I changed my skin to classic, every time I restarted Yahoo I got the Indigo skin back. The only solution I found for this is going to Program Files/Yahoo!/Shared/Graphics and delete/rename the Indigo and Maverick folders. Now Yahoo looks and feels like the low profile/high utility app that it's supposed to be.

and has 0 comments
"How can you say that, Siderite, since all your rants are typical intellectual rants and you are obviously one?" writes a loyal blog reader.

Well, loyal reader, only reader and also writer of this blog, I also suck! Yes. Writing a blog that basically helps no one except for the programming tips, for the main purpose of being read by anyone, shows that I suck big time. And I am not the only one. Forums and blogs are sprouting all over the net, an infestation marketed as Web 2.0, basically saying absolutely nothing useful. The writers usually start blogging for the same reason that young girls write diaries, then "accidentally" leave them so anyone can read them. The opinion of people we don't care about and that normally should not care about us should be irrelevant, but the human need for self affirmation seems to counteract this obvious logic.

And I've realised this (well, finally at a conscious level) by reading these small magazines that are free and left to be read in bars and restaurants. They contain a few articles, targeting medium or high income young adults, as most of the clientele of this places is, and written by intellectuals. The rest of the pages are filled, of course, with commercials and ads. I first got interested, because the things that these guys said resonated with my own thoughts. Then I realized that they only did so with negative thoughts, talking about how the world is and shouldn't be and the adjacent sarcasm and intelligent irony. They didn't really provide useful solutions; and the more I read them, the more they sounded like whining.

So it hit me! These people have no reason to write anything to others. They only express their own impotence as members of the most elitist and minority group: intellectuals. They are intelligent, they read a lot, know a lot, and can't do anything about it. They are surrounded by idiots and the world these idiots create and the only possible thing to do about it is BLOG! (as in rant, using any media they can access). And because their opinion is nothing more than a sad whine, with no effect whatsoever, they suck. And so do I!

and has 0 comments
Why Windows takes so long to shut down.

Now this is a nice article that just touches my soul. How many of us, computer geeks have been at the mercy of the Windows shutdown? How many minutes wasted staring blindly into the monitor for that simple but elusive power off?

I have installed the Hive Cleanup Service and it mostly works. However, I can't say that it provides with the instant shutdown that I was looking for and I have no idea if the fact that my computer shuts down regularily now is due to this software, but it certainyl didn't hurt my computer in any way.

and has 0 comments
Profile of the Sociopath

This link is a short summary of the psychological profile of a sociopath. Having dealt with at least two in my life, and with one when I was least prepared for it (Grrr!), I kinda stumbled over this. As a paranthesis, search on Google for cult leaders and their psychological profile. Some weird event from your adolescence or the strange behaviour of your child can be sometimes explained by the influence of sociopathy and cultism.

If you read carefully the link above, a pattern forms and a profile of a sociopath emerges. Are they many in society today? And asking myself that I noticed that this profile fits a lot of women almost like a glove. Don't believe me? Read it for yourself. Of course, it doesn't ALL fit, else we would be in big trouble, but I started wondering, as the defining characteristic of psychopats is the incapacity for love and shallow emotions, how do women feel? Could that be an explanation for the way we can't understand the opposite sex, while they understand us perfectly? Could it also explain while we get mad rather rarely, but intensely, while they seem to get enraged after all kind of stupid things, then quickly get over it? Do they really love? These are questions that stuck with me for days.

Of course, a general and simple answer doesn't exist. If I look closely, a lot of those traits fit me as well. Does it mean I am a sociopath, coolly manipulating my blog readers? I just might :D

I somehow managed to add to one of my Visual Studio 2005 Web Projects a webservice that had the code written "inline" meaning the <%@ WebService Language="C#" Class="WService"%> tag, followed by the C# code. While Visual Studio has a decent Intellisense functionality in asmx files, ReSharper doesn't. So I felt the need to move the code into a codebehind file. You would think that adding the Codebehind="WService.amsx.cs" would be enough. No, it isn't! As the codebehind model for VS is to have the codebehind in a compiled dll, an error like "Cannot create type WService" will annoy the hell out of you. The solution is to add the cs file into the App_Code directory.
<%@ WebService Language="C#" Class="WService" Codebehind="~/App_Code/WService.asmx.cs"%>

I've tried compiling and using a dll from the net for a Pocket PC and, even if the compilation of the source worked, when trying to add it as a reference, I got an error and the dll would not show in the references. However, a lot of other errors occurred later on, as if the dll was still referenced. Reading the csdproj file directly, I noticed that the reference to the dll was there, but that every time the project was loaded, the same error occurred and the reference did not show. The only solution is to remove with a text editor the XML entry from the csdproj file.

Also, VS2003 hangs periodically after a few debug-deploy cycles, usually when trying to stop debugging, using 100% CPU and freezing. This might also be related with version 2.0 of ReSharper which I have installed, but somehow I doubt it, cause I love the guys at JetBrains! :) The only solution is to kill the process, which will close VS2003, then restart it and reload the project.

Another issue is with the file on the Palm being in use while you try to deploy. The solution is to get to the Palm Control Panel, go to Memory, select the Running Programs, kill any program that has the same name as the program you want to deploy and anything that looks like "Client".

There are other issues, but I don't care to remember them all B-)

How to: Reference ASP.NET Master Page Content:
You must use a MasterType tag in each page to define the exact master page used. After that, all public members and properties in the MasterPage will be available in code as
Master.PropertyOrMember="RightHand";