how to find control in headertemplate of datagrid

Discussion in 'ASP .Net' started by Cheng, Feb 29, 2004.

  1. Cheng

    Cheng Guest

    hi
    i have adding a label in the headertemplate of a datagrid
    i have write the code to find it;

    //my code
    Label lbl = (Label) DataGrid1.FindControl("myLabel");

    but i can't find it
    what is the right method that i can find it?

    thank you :p
     
    Cheng, Feb 29, 2004
    #1
    1. Advertising

  2. Try iterating thru the DataGridItems in your datagrid and use the DataGridItem.FindControl("idofyourcontrol") method to find your label control.

    Suresh

    ----- Cheng wrote: ----

    h
    i have adding a label in the headertemplate of a datagri
    i have write the code to find it

    //my cod
    Label lbl = (Label) DataGrid1.FindControl("myLabel")

    but i can't find i
    what is the right method that i can find it

    thank you :
     
    =?Utf-8?B?U3VyZXNo?=, Feb 29, 2004
    #2
    1. Advertising

  3. Cheng

    dany7487

    Joined:
    May 29, 2007
    Messages:
    2
    use the HeaderRow !

    I think the solution to access controls inside the headertemplate is:

    ctr = grid1.HeaderRow.FindControl("ckbCheckAll");
    if (ctr is CheckBox)
    {
    (ctr as CheckBox).Checked = true;
    }

    hope this helps,
    Daniel.
     
    dany7487, Nov 14, 2007
    #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. SamIAm
    Replies:
    1
    Views:
    4,572
    Bipin Joshi [MVP]
    Jun 26, 2003
  2. Vijaya
    Replies:
    2
    Views:
    2,665
    Vijaya
    Nov 13, 2003
  3. Ashish Sharma

    DataGrid HeaderTemplate Question

    Ashish Sharma, Apr 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Ashish Sharma
    Apr 14, 2004
  4. JoNa SuperGold

    controlling button in headertemplate datagrid

    JoNa SuperGold, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,155
  5. Vijaya

    Can we bind data to textbox in a headertemplate of a datagrid

    Vijaya, Nov 12, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    223
    Pramod Anchuparayil
    Nov 12, 2003
Loading...

Share This Page