how to find control in headertemplate of datagrid

C

Cheng

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
 
G

Guest

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 :
 
Joined
May 29, 2007
Messages
2
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top