how to update a primary key in a gridview?

D

Dan

Hi,

I defined a gridview with an UpdateCommand.
When i click on 'update' i can update all fields excepted the primary key.
Is there any way to make it possible?
(I use Access and when runing a update-query in Access, i can also update
the primary key).

Thanks
Dan
 
M

Matt

Do you really want to update the primary key? Or do you just want to
pass the primary key to the update method?
 
D

Dan

I want to update the primary key. It must be possible to do it. For
instance, when the primary key is not auto-generated.
Is this possible with a gridview?
Thanks
 
C

CaffieneRush

It's normally not a good idea to update the table keys.
Your case of the primary key not auto-generated is relevant to inserts
but not updates.

However in case you have one of the rare cases where it is absolutely
neccessary to update keys - the primary key names are in
GridView.DataKeyNames and the values are in GridView.DataKeys.

Regards,
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top