HighTechTalks DotNet Forums  

Displaying the id/PK in a gridview?

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Displaying the id/PK in a gridview? in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
eagle
 
Posts: n/a

Default Displaying the id/PK in a gridview? - 07-18-2007 , 09:15 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.



Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Displaying the id/PK in a gridview? - 07-19-2007 , 05:02 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


"eagle" <eagletender2001 (AT) yahoo (DOT) com> wrote

Quote:
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.





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.