[quoted text, click to view] "John" <John@nospam.infovis.co.uk> wrote in message
news:OksLeHfyGHA.4092@TK2MSFTNGP04.phx.gbl...
> I have a hidden (visible=false) column on a gridview bound to a sql server
> table. I am trying to access the field as;
>
> For Each row As GridViewRow In grdEvents.Rows
> If row.RowType = DataControlRowType.DataRow Then
> bf = CType(row.Cells(row.Cells.Count - 1).FindControl("event id"),
> BoundField)
> End if
> Next
>
> but I get the 'System.Web.UI.Control' cannot be converted to
> System.Web.UI.WebControls.BoundField' error.
Hmm - not precisely certain what you're trying to do here... Clearly, you
don't actually need to convert a column into a BoundField or anything else
just to interrogate its contents...
[quoted text, click to view] > When I try to access it using row.Cells(12).Text then it returns a blank
> value.
Sounds like you've discovered one of the new features of GridViews, whereby
hidden columns are not saved in ViewState by default...
[quoted text, click to view] > How can I access the relevant gridview column?
Set the column Visible = True immediately before calling the GridView's
DataBind method, then set it Visible = False immediately afterwards...