Groups | Blog | Home
all groups > asp.net datagrid control > july 2007 >

asp.net datagrid control : Displaying the id/PK in a gridview?



eagle
7/18/2007 7:15:38 AM
So how does everyone hide the primary key in a gridview with a datasource to
a table, let's say. If you don't display it, then you can't update the
records. Users don't want to see this field, particularly if it's a guid.
Example:

Select ID, ProductName from tblProducts is the datasource

The gridview has 2 bound fields, the id and the productname. If you set the
id to invisible, it's not rendered and it is lost when you attempt to update
that record.

Eliyahu Goldin
7/19/2007 12:00:00 AM
Add "ID" to the DataKeyNames property and take out of the query.


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


[quoted text, click to view]

AddThis Social Bookmark Button