RobAinscough
asked on
WebControl.GridView bug?
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.
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.
ASKER
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).
Rob.
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).
Rob.
Hi well i had the same problem and to work around it I made the field a TemplateField
Hope helps
Hope helps
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim iSelectedRow As Integer = 2
gv.SelectedIndex = iSelectedRow
Label1.Text = gv.SelectedRow.Cells(6).Te