GridView hide datakey

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have my gridview bound to a objectdatasource control and the only thing I
need to hide on the grid is the primary key but I need the key in the dataset
that refers to it.

With a dynamic approach the column can be hidden at a certian point in the
rendering cycle. As I have learned today my grid never offically has a
column(0) and I would think anyone who ever uses the gridview would want to
hide the primary key!

Where/how/when can I hide this sucker..?
 
Sean,

Just delete the column and put the field name of your primary key (ie
CustomerID) in the GridView's DataKeyNames property. This can then be
referenced on postback. It also comes thru the GridView.SelectedValue
property when it has been selected.

HTH,
Chris
 

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

Back
Top