473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

GridView ObjectDataSource hidden columns

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

Feb 7 '07 #1
2 2235
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.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"Steven Nagy" <le*********@hotmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
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

Feb 7 '07 #2
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.

Feb 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frank | last post by:
Hello All, I am working with VS.NET 2005 and I have an editable GridView whose HTML markup is shown below. In short, when the user clicks on the Edit button, one of the textboxes is replaced...
0
by: Frank | last post by:
Hello All, I am working with VS.NET 2005 and I have an editable GridView whose HTML markup is shown below. In short, when the user clicks on the Edit button, one of the textboxes is replaced...
0
by: Michel | last post by:
Hi, i programmed a asp.net 2.0 gridview to a objectdatasource. when i show all the columns of the object in the gridview and i click edit and update, i get the whole object with all it's params...
0
by: =?Utf-8?B?cGI2NDgxNzQ=?= | last post by:
We have been having this problem for months and always assumed it was because of our somewhat complicated setup. I have just spent almost all of today making this into a simple example that can be...
4
by: Tomasz | last post by:
Hello Developers, Here is interesting problem I just came across: how do I wire a GridView control programmatically? Here is my sample code using Object Data Source: protected void...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
2
by: rgparkins | last post by:
So, I've bitten the bullet and am converting some of my asp.net 1.1 sites to asp.net 2.0, now after many issues I have come to a stop with the objectdatasource and gridviews and maybe someone can...
2
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
Based on wether a row is selected in a GridView I need to HIDE the last two columns of a gridview. I do NOT need to make the cells invisible I want to hide the entire column. When I set the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.