Datagrid and hidden unique ID columns

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,

I am using Datagrid quite a lot to show lists of items from a database
that I might want to delete / edit.

These database entries are uniquely identified by a single integer ID
field and when I edit/delete I want to use this primary key to pass
into stored procedures used to edit/delete the item.

Since the user does not know or care about seeing this ID field in the
grid the solution that I use at the moment (and I dont really like it)
is to return the ID field when I query the database and include in the
grid but I set the visibility of the column showing that would display
this ID value to "false" so that the user cannot see this but I can
get at this data when edit/deletes are performed.

Surely there is a 'better' way to do this?? If so I like to know!!

Thanks,

Paul
 
Paul said:
Since the user does not know or care about seeing this ID field in the
grid the solution that I use at the moment (and I dont really like it)
is to return the ID field when I query the database and include in the
grid but I set the visibility of the column showing that would display
this ID value to "false" so that the user cannot see this but I can
get at this data when edit/deletes are performed.

Surely there is a 'better' way to do this?? If so I like to know!!

The grid's DataKeyField sounds like what you need.
http://tinyurl.com/29qb4

Andy Mackie
 
Just curious, why don't you like this technique

Tu-Thac

----- Paul wrote: ----

Hi

I am using Datagrid quite a lot to show lists of items from a databas
that I might want to delete / edit

These database entries are uniquely identified by a single integer I
field and when I edit/delete I want to use this primary key to pas
into stored procedures used to edit/delete the item

Since the user does not know or care about seeing this ID field in th
grid the solution that I use at the moment (and I dont really like it
is to return the ID field when I query the database and include in th
grid but I set the visibility of the column showing that would displa
this ID value to "false" so that the user cannot see this but I ca
get at this data when edit/deletes are performed

Surely there is a 'better' way to do this?? If so I like to know!

Thanks

Pau
 
Back
Top