I am working on this windows app that uses Crystal Reports. I've never used it before and I thought "Hey! I could learn something new". So I opened this .rpt file in Visual Studio 2003 and I got the most incomprehensible interface ever. I mean, I will have to invest some hours just to understand what the report interface is all about.

But anyway, I thought I would take an existing report and then just change something, like adding a new field. I went with the mouse on an empty space, right click, context menu, Insert... I could insert text. I could insert Special Fields (report data like number of the page, creation date and so on). I could insert Fields. Only that option was disabled! I've tried every option in the context menu, no avail.

Finally I've decided I am to dumb to figure it out, I went to man's best friend: Google! The answer found in an obscure forum was:
- Go to View (in Visual Studio 2003)
- click Other Windows
- click Document Outline

Now a Field Explorer window is open and I can see all fields and drag them to the report. That was it! :-/

and has 2 comments
When one wants to replace a text, say, case insensitive, one uses the .NET Regex class. In order to make sure the text to be replaced is not interpreted as a Regex pattern, the Regex.Escape method is used. But what about the replacement string? What if you want to replace the text with "${0}", which in Regexian means "the entire matched string" ? You need to somehow escape the replace pattern.

I have no idea where to find this information on MSDN, although I am sure it is hidden somewhere in all that Regex labyrinth. Here is the link on MSDN: Substitutions

So here is the info: You only need escaping the dollar sign, so the code would look like this:

Regex reg=new Regex("Text to replace",RegexOptions.CaseInsensitive);

string s="here is the text to replace";

s=Regex.Replace(s,"$${0}");

Now the value of s is "here is the ${0}".

and has 0 comments
Yes, we went to the Mitsubishi dealership. It was nice to actually have someone talk to us and give us all the details, thing that did NOT happen to us at any showroom except the Seat part of the Skoda showroom.

As a side note, I tried entering the Pajero, the Mitsubishi SUV and... I couldn't fit. Not even a tortured position. The front seat moves electrically (yes, some people are so lazy that moving their own seat takes too much. My foot was turned at 90 degrees, my leg could not find a proper position and it wouldn't pass past the steering. It was horrible. But then it dawned on me: tall people don't buy SUVs! The usual suspects when we're talking SUV drivers are fancy women and small, fat people. You don't buy an SUV because you need it, but because it compensates for some shortcomings (pun intended).

Now, back to the car we preordered!! The Mitsubishi Colt is a normal droplet shaped hatchback. But I could fit in! A little effort was required on the driver's seat, but it was ok. More than that, I am sure the rails of the seat can be lengthened or at least moved a little back. The back seats also move back! You can also collapse them or even remove them entirely, giving a huge space in the back if there are only one or two people in the car. It also has automatic gear shifter, which is terribly difficult to find in small cars (or any cars for that matter) in Romania; yet, unfortunately, only the gasoline car models. No matter. I was looking for a gasoline car anyway. The color choice was rather poor, I had to choose between white, black, gray and red nuances.

So, we preordered the car! A carmine Mitsubishi Colt Hatchback, 1.3 Gasoline, Automatic/manual gearbox (that means you can switch between them whenever you like).

Now, all we have to do is get the money (from a bank!) and pay a lot of money every month for 5 years. Wish us luck!

and has 0 comments

Without further ado, The Sounds! with their song "Seven Days a Week". Of course I chose this one because the blond looks cute :)



Links: Official site, MySpace site, Wikipedia entry, YouTube search.

and has 0 comments
No, I am not talking about Dark Water, either. I am talking about water. Penn and Teller went to a rally of some sort and asked people to ban dihydrogen monoxide; water, that is...



So, if you are reading this, dear environmentalists and conspiracy theorists... don't listen to everything that sounds good, because most of it is not, even if it seems to enter the same agenda as yours...

and has 0 comments
A while ago I wrote this entry about an innovation in sound technology that will probably change the way we think of sound.

Today I am presenting a video technology I witnessed at the mall! Yes, the mall, that dreaded place of overpriced junk and overdressed bimbos. Overpriced, too! :) Anyway, I was watching this Pepsi commercial on a big TV like device, where a can of Pepsi was rotating showing its full cylindrical glory. Only that it felt out of focus. My eyes were kind of sore watching it. Immediately the image changed to a ball that came towards the screen and then... went through the screen!

It worked from almost every angle, without being a holographic thing in the middle of the air, but more of an optical illusion. Thinking of the faithful thousands of people reading this blog every day, I remembered the little link on the side of the device: www.x3d.com, with their device called MultiView.

The image is not as clear as one would want. It's like continuously vibrating or something like that, but the optical illusion is great! I saw people passing by the device and trying to put their hand through the "flying" objects.

Here are a few links from Wikipedia about the subject:
Volumetric Display
Autostereoscopic

I found this little page while searching for a DataGridDropDownListColumn for NET 1.1 Windows Forms. It works and seems elegant enough.

To bind the column values, use column.myComboBox.DataSource, DisplayMember and ValueMember.

and has 0 comments

Update: I've heard that Fado has now been closed. It was nice while it lasted. Too bad I didn't have the chance to go again a few times before it went away.

Today we went with my parents at a Portuguese restaurant called Fado. I have to say I was pleasantly surprised by the cuteness of the place and the service was not bad. The food was bravely innovative, too, and tasty. Actually, it was more on my own taste than most of the restaurants I've been to, including Chinese. Well, I like Chinese more, but I can't cook Chinese, that's what I meant :-P

Anyway, if you happen to search for an intimate restaurant in Bucharest, with interesting food and a waiter that knows suspiciously much about the food, up to the point where he recommends you what is better than your original idea, then Fado is the place for you.

This is a link, in Romanian, with more details: Restaurant Fado

If you look for solutions to get rid of huge ViewStates from your pages you will get a lot of people telling you to override SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium in your pages and do complicated stuff like keeping the ViewState in the Cache or in a database, calculating strange keys, etc.

No more! Net 2.0 has something called a PageStatePersister. It is an abstract class and every Page has one. In case no override occurs, the default is a HiddenFieldPageStatePersister, but you can also use the provided SessionPageStatePersister like this:
protected override PageStatePersister PageStatePersister
{
get
{
return new SessionPageStatePersister(this);
}
}


And that's it! It works with Ajax and UpdatePanel, too.

However, this is no "Silver Bullet", as the SessionPageStatePersister will have issues with multiple windows open with the same session (like pop up windows) as exampled in this nice article. Also check out this situation when, during Ajax callbacks, a full ViewState is returned due to the ever troublesome ImageButtons.

There is no reason not to create your own PageStatePersister, though. The abstract class is public (not internal and sealed as Microsoft likes their most useful classes) and you can inherit it. You can even store the state in the Cache! :)

A very comprehensive article on ViewState is here.

and has 0 comments
A while ago I wrote a post about the bug in the DataTable.Select method with columns with comma in their names.

Today I discovered another bug, when using DataTable.Select with an empty sort string, but not an empty filter string, there is an implicit sorting by the first column. Short example: a DataTable with a single column called "words" containing values c,b,a,d , when Selected with a filter like "words is not null" and a null or empty sort string, will return a,b,c,d.

The only solution for this was to drop DataTable.Select entirely and use DataView, with its NET 2.0 method DataView.ToTable. So the code to take a DataTable and return the filtered and sorted table would look like this:
public static DataTable Select(DataTable table, string filter, string sort)
{
if (table == null) return null;
var dv=new DataView(table);
dv.RowStateFilter=DataViewRowState.CurrentRows;
dv.RowFilter = filter;
dv.Sort = sort;
return dv.ToTable();
}

But DataView has the same problem with columns with comma in their names. We solve it in the same way we solved it in the previous post: we change the column names, the sort and filter strings, we select, then we change the column names back:
public static DataTable SelectSafe(this DataTable table, string filter, string sort)
{
var originalColumnNames = new Dictionary<string, string>();

foreach (DataColumn dc in table.Columns)
{
if (dc.ColumnName.IndexOf(',') > -1)
{
var columnName = dc.ColumnName;
var safeColumnName = columnName.Replace(",", ";");
var reg = new Regex(Regex.Escape("[" + columnName + "]"), RegexOptions.IgnoreCase);
dc.ColumnName = safeColumnName;
if (!String.IsNullOrEmpty(filter)) {
filter = reg.Replace(filter, "[" + safeColumnName + "]");
}
if (!String.IsNullOrEmpty(sort)) {
sort = reg.Replace(sort, "[" + safeColumnName + "]");
}
originalColumnNames[safeColumnName] = columnName;
}
}

var newTable = Select(table, filter, sort);

foreach (KeyValuePair<string, string> pair in originalColumnNames)
{
table.Columns[pair.Key].ColumnName = pair.Value;
newTable.Columns[pair.Key].ColumnName = pair.Value;
}
return newTable;
}

and has 0 comments
At first I thought it wasn't Linkin Park singing. The sound is a bit different, at least in this song. But I like it. I hope this new album of theirs, Minutes to Midnight, will be as good as their first.


There is an article here that explains it better than I would. Basically, the new Visual Studio is finally released in beta and is supposed to be the IDE for .NET and Vista.
The .NET Framework 3.5 (that is 2.85 in normal versioning? :D ) is also to be released here.

and has 0 comments

I know, the third entry in my blog about Basescu doesn't say much about my IQ or style, yet now I know what I felt I needed to say, but didn't realise what it was. It is the similarity between the case of Traian Basescu and Ariel Constantinof.

It is amazing still that these two similar stories happened in the same time. Indeed, Basescu is like a high school student who is suspended from the school on the basis of his behaviour, without anyone really knowing if it is "kosher" to do so. Do the high school owners have the right to expel Basescu or is this a financially motivated blunder? Both of them are big mouthed smart asses, without being really malevolent, yet being rather naive. Just as Basescu, Ariel gets a lot of sympathy from bloggers and radio hosts (radio bloggers?) everywhere, but without any true support. On each of the blog pages that describe his ordeal there are hundreds of people that offer their moral support, but really not much else. Just as Ariel, Basescu gets only a bunch of people to at least voice their anger to the school directors.

Can the case of Ariel Constantinoff serve as a simulation of what will happen to the country in a few months? I don't know, but I really like Ariel more than Basescu. And at least he has parents, the chance to go to another school. For crying out loud, he's a kid! Teachers, leave the kids alone! But who will find enough sympathy in their hearts for an old, bald, shunned ex president who didn't yet catch on with reality?

That's it! No more Basescu for a while on this blog ;)

I just remembered this song and, since I haven't been posting music lately on the blog, I put it on. The clip is made by fans of both Lou Reed's song and of the movie Trainspotting, also a favourite of mine, which featured A Perfect Day in the soundtrack. Enjoy!

A previous post of mine detailed the list of ASP.Net controls that cannot be used with UpdatePanel and ASP.Net Ajax. Since I provided a fix for the validators earlier on, I've decided to try to fix the Menu, as well. And I did! At least for my problem which involved using a two level dynamic menu inside an UpdatePanel.
Here is the code:
<script>
function FixMenu() {
if (typeof(IsMenuFixed)!='undefined') return;
if (!window.Menu_HideItems) return;
window.OldMenu_HideItems=window.Menu_HideItems;
window.Menu_HideItems=function(items) {
try {
OldMenu_HideItems(items);
} catch(ex)
{
if (items && items.id) {
PopOut_Hide(items.id);
}
}
}
IsMenuFixed=true;
}
</script>

Now all you have to do is load it at every page load:
ScriptManager.RegisterStartupScript(this,GetType(),"FixMenu","FixMenu();",true);


Explanation: the error I got was something like "0.cells is null or not an object", so I looked a little in the javascript code, where there was something like " for(i = 0; i < rows[0].cells.length; i++) {" and rows[0] was null. All this in a function called Menu_HideItems.

Solution 1: Copy the entire function (pretty big) and add an extra check for rows[0]==null.

Solution 2: Hijack the function, put it in a Try/Catch block and put the bit of the original function that appeared after the error in the catch. That I did.