• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

How to Read the value of a Gridview Cell that is not Visible

The visible property of a gridview cell is set to false.

Cells[3] definition:

<asp:BoundField DataField="ToDate" HeaderText="ToDate"
                    ReadOnly="True"
                    Visible="False" />

grdWatchList.SelectedRow.Cells[3].Text  Returns ""

What is the syntax for returning the value of the not visible cell?

Thanks,
0
Dovberman
Asked:
Dovberman
1 Solution
 
abelCommented:
You can use the same syntax you would for a visible control, provided the control has a value. A control with Visible=False will not be rendered to the browser, but on the server you can access all properties. If you are getting nothing, then the cause must lie somewhere else.
0
 
GiftsonDJohnCommented:
Hi,

If you put <asp:BoundColumn Visible=false /> the contents won't be stored in the viewstate. If it is not there in viewstate then you won't be able to get in server events of the GridView.

This behavior is not there in DataGrid but is there in GridView. So in order to view the values of the cell in GridView events, don't say Visible=false, instead set the display style to none in the RowDataBound event.

e.Row.Cells[1].Style["display"]="none";
0
 
DovbermanAuthor Commented:
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now