Findcontrol on Gridview Boundfield?? Type Label?

  • Thread starter Thread starter wildman
  • Start date Start date
W

wildman

re: Findcontrol on Gridview Boundfield?? Type Label?

In the row command event I've been able to pull the value of a cell as
follows when the cell was produced from from an itemtemplate as
follows:


Dim xxx As String = CType(row.FindControl("pointDate"), Label).Text

However, the above gives me error "Object reference not set to an
instance of an object."

I know I can get the value using

Dim xxx as String = row.Cells(1).Text

But I'd rather not have hard coded positions.
 
Dim xxx As String = CType(row.FindControl("pointDate"), Label).Text
Dim xxx as String = row.Cells(1).Text

They're actually not the same thing...

The first line implies that there is a Label control inside the Cell, but
the second implies that there isn't...
 
They're actually not the same thing...

The first line implies that there is a Label control inside the Cell, but
the second implies that there isn't...

True and no doubt the problem.

What does a Boundfield of a Gridview become so that I can do a
Findcontrol on it rather than specifying a cell number? I could sware
that code use to work. Perhaps in only works in a particular mode.

thanks.
 
Back
Top