Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2008

Tip: Looking for answers? Try searching our database.

reading hidden data from a gridview control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul - 30 Jun 2008 16:38 GMT
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);
Signature

Paul G
Software engineer.

Eliyahu Goldin - 30 Jun 2008 16:40 GMT
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);
Mark Rae [MVP] - 30 Jun 2008 16:46 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.