Thursday, November 4, 2010

GridView value set to null when column is not visible

You made an Update method to take care of updating your gridview, but there are some columns that are not needed to be shown in the default gridview but you do need them in the update method.
Then, when you try to use those columns data in your method, you will see they have null even though they had value in them...

What can you do then ?

Write those column name in the DataKeyNames section of gridview control. Then, those columns will be available and not with null value in your update method.
 



Good luck.