Accesing the Header Row

4 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 23 Sep 2009 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Sep 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 24 Sep 2009 Link to this post

    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.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2009 Link to this post

    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.
Back to Top