GridView ObjectDataSource hidden columns

S

Steven Nagy

Hi,

I am painfully aware of the fact that with a GridView bound to an
ObjectDataSource that if you have a hidden grid column (visible=false)
then it does not post back that field to your objectdatasource for
update/insert/etc.

The workaround I have found is to include all your field names in the
DataKeys attribute, and this forces all information about an object to
be called against your object Update command. But to me, this is a bit
smelly.

Is this the best solution? Is there a better way to handle this?
What happens when I want to specify a second ObjectDataSource who's
select method uses the ID of the selected row in the GridView (which
uses the DataKey property) ?

Cheers,
Steven
 
E

Eliyahu Goldin

If I need to hide a control that I want to either use on client side or get
back on postbacks, I do it with setting css rule display:none.
 
S

Steven Nagy

Ok so rather than setting visible=false, I apply a style to the column
and hide it that way.
This would certainly cause it to postback the values.
And it free's up the DataKeys attribute so it can contain actual keys
only.

Thanks.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top