This is a migrated thread and some comments may be shown as answers.

Accesing the Header Row

3 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 23 Sep 2009, 07:31 PM
Hello,

I customized the header row of the radgrid, and I cannot figure out how to access it.  How do I get access to the header row in code-behind?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2009, 04:42 AM
Hello Brian Mains,

You can access the header row of your grid as shown in the sample below:
c#:
 protected void RadGrid1_ItemDataBound(object  sender, GridItemEventArgs e)  
   {  
      if (e.Item is GridHeaderItem)  
       {  
           GridHeaderItem header = (GridHeaderItem)e.Item; //to access header row 
           string strtxt = header[ "CustomerID"].Text; //to access the text for a column header        
       }  
   }   

Thanks
Princy.
0
Brian Mains
Top achievements
Rank 1
answered on 24 Sep 2009, 01:26 PM
Hello,

That isn't going to work in my situation, because I need to access it in a postback after it's already been bound, before I bind its data.  This is because I need to access some custom controls I put within the header template.  But the first item is always a GridDataItem, not a header item...  so can I access it any other way?
 
Thanks.
0
Shinu
Top achievements
Rank 2
answered on 24 Sep 2009, 01:48 PM
Hi Brian,

You can try out the following code to access the header template control after a postback:
c#:
GridHeaderItem header = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0];  
Control cntrl = (Control)header.FindControl("ControlID");  

Thanks
Shinu.
Tags
Grid
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Brian Mains
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or