Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Findcontrol on Gridview Boundfield?? Type Label?

Reply
Thread Tools

Findcontrol on Gridview Boundfield?? Type Label?

 
 
wildman@noclient.net
Guest
Posts: n/a
 
      02-14-2008
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.






 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      02-14-2008
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
 
 
 
wildman@noclient.net
Guest
Posts: n/a
 
      02-14-2008
On Feb 14, 12:03*pm, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > 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...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FindControl in GridView Bruno Alexandre ASP .Net 3 09-01-2008 10:26 AM
FindControl to reference nested controls in gridview/listview Martin ASP .Net 4 04-10-2008 10:08 AM
Losing Hope! FindControl of dynamic gridview not working K B ASP .Net 2 09-17-2007 12:27 AM
FindControl on GridView Cell returning null saha ASP .Net 0 06-25-2006 06:50 PM
Gridview's findcontrol ignores cells() Edwin Knoppert ASP .Net 0 11-25-2005 09:17 AM



Advertisments