GridView ObjectDataSource hidden columns

  • Thread starter Thread starter Steven Nagy
  • Start date Start date
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
 
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.
 
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.
 
Back
Top