Findcontrol on Gridview Boundfield?? Type Label?

Discussion in 'ASP .Net' started by wildman@noclient.net, Feb 14, 2008.

  1. Guest

    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.
    , Feb 14, 2008
    #1
    1. Advertising

  2. <> wrote in message
    news:...

    > 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
    Mark Rae [MVP], Feb 14, 2008
    #2
    1. Advertising

  3. Guest

    On Feb 14, 12:03 pm, "Mark Rae [MVP]" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > 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.
    , Feb 14, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmVuamFtaW4=?=

    ImageField and BoundField columns in a gridview control:

    =?Utf-8?B?QmVuamFtaW4=?=, Apr 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,690
    =?Utf-8?B?QmVuamFtaW4=?=
    Apr 20, 2004
  2. sck10
    Replies:
    6
    Views:
    19,840
    UdayGaikwad
    Oct 24, 2011
  3. mz
    Replies:
    0
    Views:
    654
  4. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    6
    Views:
    13,358
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Apr 4, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    265
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page