Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to find control of gridview Header template on click on button which is out side gridview control.
Posted
Updated 7-Jul-16 1:41am
Comments
RelicV 5-Apr-13 3:29am    
Need more info. Please post you code and what have you done till now. How do you expect to help you without any info..?

No brainers.. No Gainers...!
Chinmaya C 5-Apr-13 5:01am    
Are you looking for a perticular control?
if so then the following code may help:
GridView1.HeaderRow.FindControl("[ControlName]") as [ControlType]

Your question is not clear, its better if you can post your code, in case if you are looking for this, might help
C#
foreach (TableCell headerCell in GridView1.HeaderRow.Cells)
    {
        // or access Controls with index
        //     headerCell.Controls[INDEX]
        Label lblHeader = headerCell.FindControl("headerLabel1") as Label;
                   
    }
 
Share this answer
 
Try this:
C#
foreach(GridViewRow gdv in GridView1.Rows){
     if (gdv.RowType == DataControlRowType.Header)
     {
         //Find the control here.
         TextBox txt = (TextBox)gdv.HeaderRow.FindControl("txt");
     }
}




--Amit
 
Share this answer
 
Use this code in RowDataBound.

C#
GridViewRow head = grid.HeaderRow;
TextBox Tbx = head.FindControl("txtItem") as TextBox;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900