Using labels in the HeaderTemplate of a datagrid or datalist

Discussion in 'ASP .Net Datagrid Control' started by ree32, Sep 21, 2004.

  1. ree32

    ree32 Guest

    when I try to access this label to place a text in it in the code. I
    get this error -
    Object reference not set to an instance of an object.


    I assume this because the label is within the datalist I can't get a
    control of it.

    Is there anyway around this?
    ree32, Sep 21, 2004
    #1
    1. Advertising

  2. Why do you want to use a lable in the header?

    "ree32" <> wrote in message
    news:...
    > when I try to access this label to place a text in it in the code. I
    > get this error -
    > Object reference not set to an instance of an object.
    >
    >
    > I assume this because the label is within the datalist I can't get a
    > control of it.
    >
    > Is there anyway around this?
    Michael Tkachev, Sep 21, 2004
    #2
    1. Advertising

  3. ree32

    ree32 Guest

    I need to use a label as the Text dynamically changes. As this
    datagrid/list is in a usercountrol. Different headings will be fed
    into the user control.
    ree32, Sep 21, 2004
    #3
  4. You can use the following code:

    datagrid.Columns[0].HeaderText = "bla-bla";



    "ree32" <> wrote in message
    news:...
    > I need to use a label as the Text dynamically changes. As this
    > datagrid/list is in a usercountrol. Different headings will be fed
    > into the user control.
    Michael Tkachev, Sep 21, 2004
    #4
  5. ree32

    ree32 Guest

    "Michael Tkachev" <> wrote in message news:<#>...
    > You can use the following code:
    >
    > datagrid.Columns[0].HeaderText = "bla-bla";
    >
    >


    You have it wrong this is not the header of the column but the header
    of the whole datagrid/datalist.
    ree32, Sep 21, 2004
    #5
  6. ree32

    Gary K Guest

    Then why is the text in a headertemplate? Anyways, to change any control in a
    template column you need to use the FindControls method. For events you can
    get away with something like, e.Item.FindControl("ctrlid"). It returns a
    general object so you will need to typecast it. Outside events I'd use
    grid.Rows.FindControl("ctrlid").

    "ree32" wrote:

    > "Michael Tkachev" <> wrote in message news:<#>...
    > > You can use the following code:
    > >
    > > datagrid.Columns[0].HeaderText = "bla-bla";
    > >
    > >

    >
    > You have it wrong this is not the header of the column but the header
    > of the whole datagrid/datalist.
    >
    Gary K, Sep 23, 2004
    #6
    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. Nevyn Twyll
    Replies:
    8
    Views:
    1,867
  2. Fahim
    Replies:
    0
    Views:
    479
    Fahim
    Aug 18, 2006
  3. jobs at webdos
    Replies:
    2
    Views:
    924
    jobs at webdos
    Oct 8, 2006
  4. Replies:
    1
    Views:
    449
  5. Andy B.
    Replies:
    0
    Views:
    778
    Andy B.
    Feb 20, 2009
Loading...

Share This Page