update a key field in a gridview

In ASP.NET 2.0 with C# I have a page with sqldatasource and a gridview.
the gridview datakeynames consists of 2 fields. I have a demand to update one of the key fields the second key.
I thought of including in the gridview another invisible field that will keep the old value of the second key
and in the update command I will point in the where clause to this field. but the problem is that
the GridViewUpdateEventArgs.oldvalues does not contain the key at all in its list because it is a key field.
How can I update a key field in a gridview?
Who is Participating?
Pratima PharandeConnect With a Mentor Commented:
See this link


Using this you can use the invisible column(hidden)

This is a trick because gridview dosen't support hidden columns

hope this helps you :)
ANAT2403Author Commented:
You link helped me a lot and I even improved it and made it more simple.
I declared in the gridview a field that is not hidden and only in the Page_Load I made it hidden.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.