WebControl.GridView bug?

Posted on 2006-03-29
Last Modified: 2012-06-27
I'm trying to retrieve a value I placed in a grid view column that is set to NOT visible:

gv_Units is the GridView control

Dim gvRow As GridViewRow
For Each gvRow In gv_Units.Rows

    Dim someValue as string = gvRow.Cells(6).Text

Next gvRow

If column 6 is not visible SomeValue = ""
If column 6 is visible SomeValue = "myvalue"

Is this a known bug with GridView?  Please tell me this is NOT a "design feature".  Any workarounds?

Thanks, Rob.
Question by:RobAinscough
    LVL 28

    Expert Comment

    do it like this

            Dim iSelectedRow As Integer = 2
            gv.SelectedIndex = iSelectedRow
            Label1.Text =  gv.SelectedRow.Cells(6).Text

    Author Comment

    Being a selected row is not relevant.

    I discovered the solution, setup a CSS style (i.e. NoVisibleText) that is "display:none" -- assign the CSSClass for each of the column properties (i.e. ControlStyle.CSSClass = NoVisibleText, ItemStyle.CSSClass = NoVisibleText, HeaderStyle.CSSClass = NoVisibleText, FooterStyle.CSSClass = NoVisibleText) -- Keep the Column Visible property = True (this must be true or the cell value can never be retreived).

    LVL 4

    Expert Comment

    Hi well i had the same problem and to work around it I made the field a  TemplateField

    Hope helps

    Accepted Solution

    PAQed with points refunded (125)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now