Findcontrol on Gridview Boundfield?? Type Label?

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.
 
M

Mark Rae [MVP]

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...
 
W

wildman

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top