Archive

Archive for August, 2008

GridViewCommandEventArgs.CommandName problem in Visual Studio.Net Cassini

August 4th, 2008 Scott Lilly Comments off

I ran into an extremely frustrating problem with GridViewCommandEventArgs.CommandName this weekend.

While working with the OnRowCommand event on a GridView object in ASP.Net, the code in my code-behind page was not doing what it should have for the asp:ButtonField that I had in the grid.  So, I set a breakpoint and watched what was happening.  When the code got to the line “if ( e.CommandName == “RaiseStoryInPriority” )”, it never executed the code within the “if” statement, even though hovering over “e.CommandName” showed that the value was equal. After trying several different things (and beating my head against the wall for far too long) I tried running the code through IIS, instead of the Cassini web server that runs your code when you press F5 in Visual Studio.Net. The code worked perfectly in IIS.

I also ran into a different problem with Cassini a while back. I was using a cache object and tried to clear out a value by assigning “null” to it. That worked in Cassini, but not in IIS. In IIS, I had to use the Remove() method.

So, if you see something that looks like it should be working, but isn’t, it might be worthwhile to run it your application through IIS and see if you still have the problem. That might save you from an hour of frustration.

Categories: ASP.Net, C#, Development Tags: