Friday, November 03, 2006

Web cache gets object references - not a copy

Did you know that if your retrieve an object from the cache, such as a DataView, that the object returned is a reference to the actual object. This means that if you plan to use .RowFilter, then you can end up with concurrency issues if other users are reading from the cache too. The solution is to create a new dataview from a cached table.

Bad:
Dim dvUsers As DataView = CType(_Context.Cache.Get("Users"), DataView)
dvUsers.RowFilter = "User_No=2"

Return dvUsers("Name")

Good:
Dim dtUsers As DataTable = CType(_Context.Cache.Get("Users"), DataTable)
Dim dvUsers As New DataView(dtUsers)
dvUsers.RowFilter = "User_No=2"
Return dvUsers("Name")

Thursday, October 05, 2006

DataFormatString in a BoundField of a GridView

I had a simple little problem - the DataFormatString="{0:0}" in a BoundField was not working. After a bit of fiddling i found that the HTML Encoding was stopping it (by encoding the format string before it was applied). Simply setting HtmlEncode="False" in that BoundField fixed the issue.

Friday, September 29, 2006

Client Validators not working in Firefox & Menu Control with master pages not working

If you upgraded a .NET 1.x project to 2.0 and now have issues with Client Validators not functioning in Firefox (they work server side) or the menu control is displaying the menu items all over the place when used with master pages, then try this tip. In the Web.Config, if there is the tag:

then remove it - it is the root of all evil - unless you plan to use IE 3!
One interesting thing to note - removing it changes all of the client side id's to .NET 2's new way of doing things, so if you have written some javascript into your pages - changes may be required.

blog.start()

I am finally going to get my act into gear and start blogging. I have a few things to share, so i'll get those up in the next week. Then I need to rebuild my web site and move it to a new host. I have a few new things - personal and web dev to add to that too.