Displaying the id/PK in a gridview?

Discussion in 'ASP .Net Datagrid Control' started by eagle, Jul 18, 2007.

  1. eagle

    eagle Guest

    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.
     
    eagle, Jul 18, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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, Jul 19, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Aspinall
    Replies:
    2
    Views:
    430
    Paul Aspinall
    Nov 29, 2005
  2. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    2
    Views:
    2,419
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 4, 2006
  3. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,977
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  4. kumag
    Replies:
    2
    Views:
    399
    kumag
    Jun 26, 2006
  5. Replies:
    0
    Views:
    426
Loading...

Share This Page