Hi I am trying to read hidden data from a gridview control. This works if
the data is visible but if the column is not visible it does not return
anything, thanks.
Int32 itemp = Convert.ToInt32(e.Row.Cells[6].Text);
If you hide the column with Visible=true, it won't be rendered and won't be
in the Cells collection. Add the column to the DataKeyNames, then you can
get it the DataKeys array.

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
> Hi I am trying to read hidden data from a gridview control. This works if
> the data is visible but if the column is not visible it does not return
> anything, thanks.
> Int32 itemp = Convert.ToInt32(e.Row.Cells[6].Text);
> Hi I am trying to read hidden data from a gridview control. This works if
> the data is visible but if the column is not visible it does not return
> anything, thanks.
> Int32 itemp = Convert.ToInt32(e.Row.Cells[6].Text);
When you set a webcontrol's Visible property to false, it does not even get
rendered to the client browser.
Therefore, you will need to use CSS to hide it client-side.
Lots of examples of this are available:
http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_
en-GBGB252GB252&q=GridView+column+hide+display

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Paul - 30 Jun 2008 17:09 GMT
Hi, thanks for the responses. I ended up converting the bound column to a
template column with a lable (lblDiscID) then used Int32 itemp
=Convert.ToInt32 ( (e.Row.Cells[6].FindControl("lblDiscID") as Label).Text);
which seemed to work. Guess there are a few ways to do it.

Signature
Paul G
Software engineer.
> > Hi I am trying to read hidden data from a gridview control. This works if
> > the data is visible but if the column is not visible it does not return
[quoted text clipped - 8 lines]
> Lots of examples of this are available:
> http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_
en-GBGB252GB252&q=GridView+column+hide+display