When you make columns invisible in a GridView-control the values in those columns are ignored when doing an update. If the update function, stored proc, or whatever expects these values (particularly when you use CollisionDetection="CompareAllValues"), the update will fail.
The solution:- Add the names of the invisible columns to the DataKeyNames-properties separated by a comma, so the values are available.- Create an event handler for the GridView.RowUpdating and add the code below. This copies all "key" values to the old and new values so the update will work.
IDictionaryEnumerator restoreOldValues = e.Keys.GetEnumerator(); while (restoreOldValues.MoveNext()) { e.OldValues.Add(restoreOldValues.Key.ToString(), restoreOldValues.Value.ToString()); e.NewValues.Add(restoreOldValues.Key.ToString(), restoreOldValues.Value.ToString()); }
Remember Me
a@href@title, strike
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.