Thursday, June 14, 2007

ASP.NET 2.0 Data Controls Not Updating - Solution

Couple of extra hooks for searches: GridView, DetalsView, FormView, ASP.NET 2.0, Not Updating, Problem

Please keep in mind these solutions were put into use after much trial & effort and a LOT of google/msdn searching. Also, I suggest these solutions because they worked for me, NOT because I have a deep understanding of why they work (I have a passing understand, but nothing worth writing about).

Solution: The DataKeyNames property of the data control you're using should be set to the Primary field key of the table you're updating. Found the obscure reference here.

Alt Solution: I'm not particularly fond of this solution. It involves making a change to the properties of the (SQL Server) database you're using. In SQL Server 2005 Management Studio, setting ANSI NULLS Enabled = true seems to remove the updating problem as well, but this effects the database and potential pre-written logic on a much larger scale. Make sure you understand the repercussions of changing DB options. Why this works might be discerned from here.

Labels: , , ,