access control in header template

Discussion in 'ASP .Net Datagrid Control' started by mor, May 28, 2004.

  1. mor

    mor Guest

    I got a label control which is dynamically created inside the
    headerTemplate of template column.
    And it is part of the datagrid.


    Please teach me how to read the content of that label control?

    I cannot use FindControl() function because it is created in runtime
    based on variable.
    And everytime the number of columns is different.

    I can access a textbox control in itemTemplate with following code
    (dgassignment is the datagrid)

    dim i as integer
    dim j as integer
    dim textboxhour as textbox
    dim dgi as datagriditem

    for i = 0 to dgassignment.items.count -1
    dgi = dgassignment.items(i)
    for j = 0 to dgi.cells.count -1
    textboxhour = ctype(dgi.cells(j).controls(0), textbox)
    next j
    next i

    But I have no idea how to get the control in header, please help,
    thanks.
     
    mor, May 28, 2004
    #1
    1. Advertising

  2. Couldn't you just use the ItemDataBound event on the datagrid and test for
    the itemType = Header?

    sub DataGrid_ItemDataBound(sender as object, e as DataGridItemEventArgs)
    if e.Item.ItemType = ListItemType.Header Then
    do a findcontrol() here.
    end if
    end Sub

    HTH.
    Ben Miller
    --
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.


    "mor" <> wrote in message
    news:...
    > I got a label control which is dynamically created inside the
    > headerTemplate of template column.
    > And it is part of the datagrid.
    >
    >
    > Please teach me how to read the content of that label control?
    >
    > I cannot use FindControl() function because it is created in runtime
    > based on variable.
    > And everytime the number of columns is different.
    >
    > I can access a textbox control in itemTemplate with following code
    > (dgassignment is the datagrid)
    >
    > dim i as integer
    > dim j as integer
    > dim textboxhour as textbox
    > dim dgi as datagriditem
    >
    > for i = 0 to dgassignment.items.count -1
    > dgi = dgassignment.items(i)
    > for j = 0 to dgi.cells.count -1
    > textboxhour = ctype(dgi.cells(j).controls(0), textbox)
    > next j
    > next i
    >
    > But I have no idea how to get the control in header, please help,
    > thanks.
     
    Ben Miller [MSFT], Jun 2, 2004
    #2
    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. Chris Theis
    Replies:
    2
    Views:
    475
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    537
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,112
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    779
    Thomas J. Gritzan
    Oct 26, 2008
  5. mlt
    Replies:
    2
    Views:
    845
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page