Posted Friday, June 16, 2006 2:35:49 PM by Heidi Bautista
If you've just upgraded from ASP.NET ver 1.1 to ver 2.0 and discovered that existing pages with editable DataGrids no longer work, you're not crazy. There really is a problem with DreamweaverCtrls.
I've reported the problem to Adobe (Macromedia - Feature Request/Bug Report Form) but no reply just yet. I'll update this post when I hear back.
ASP.NET pages with an editable DataGrid do not update the database. There's no error message. The only indication is that when the page redisplays the DataGrid, it still has the old data.
Why the problem exists
ASP.NET automatically creates unique ID's for controls. For example, the 1.1 version of the .NET Framework, the ID looks like this:
For ver 2.0, Microsoft changed the naming scheme used to generate unique IDs. In ver 2.0 that same control now looks like this:
The problem is that DreamweaverCtrls relies on the naming scheme used by ver 1.1 of the .NET Framework. The code looks for the colon character when it's figuring how whether or not the editable DataGrid uses links or buttons for the edit/update/cancel functions. Since the colon doesn't exist in the ver 2.0 unique IDs, the DataGrid is not updated.
The solution isn't too bad. Only two lines of code in the source file for DreamweaverCtrls have to be modified. The downside to the solution presented here is that once modified, that version of DreamweaverCtrls will only work for ver 2.0. Not a big problem, granted, but something to keep in mind should you decide to implement this fix for your own sites.
Here are the changes that need to be made to the cs file.
Line 2018 --
int index = eventTarget.IndexOf(":");
int index = eventTarget.IndexOf("$");
Line 2054 --
int strIndex = name.IndexOf(":_ctl");
int strIndex = name.IndexOf("$ctl");
Be sure to make a copy of DreamweaverCtrls.cs before modifying it.
If you installed Dreamweaver in the default location, you'll find the source file for DreamweaverCtrls here:
C:\Program Files\Macromedia\Dreamweaver 8\Configuration\ServerBehaviors\Shared\ASP.Net\Scripts\Source\DreamweaverCtrls.cs
That folder has a bat file to assist with compilation of the C# source. For more information about compiling, see Demystifying .NET Compilers.
See Community MX content by Heidi Bautista