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

Set Value of Control in GridTemplateColumn HeaderTemplate

1 Answer 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
perry
Top achievements
Rank 1
perry asked on 27 Jan 2016, 05:45 PM

 I am able to change the values of all the controls in my telerik grid in the ItemDataBound method except those in the HeaderTemplate
How can I access those controls?

 

<telerik:GridTemplateColumn UniqueName="TemplateColumnOne" >

<HeaderStyle >

</HeaderStyle>

<HeaderTemplate >

<asp:Label ID="lblToolTip" runat="server" ></asp:Label>

</HeaderTemplate>

<ItemTemplate>

<asp:Label id="lblPermitNumber" runat="server"></asp:Label>

</ItemTemplate>

</telerik:GridTemplateColumn>

 

protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)

{

var item = e.Item as GridDataItem;

TableCell documentColumn = item["TemplateColumnOne"];

var lblPermitNumber=(Label)documentColumn.FindControl("lblPermitNumber");

lblPermitNumber.Text = "some text; // how do you access LblToolTip ?

}

 

 

I am able to change the values of all the controls in my telerik grid in the ItemDataBound method except those in the HeaderTemplate

How can I access those controls?

      <telerik:GridTemplateColumn UniqueName="TemplateColumnOne" >
      <HeaderStyle ></HeaderStyle>
      <HeaderTemplate >                                  
      <asp:Label ID="lblToolTip"  runat="server"  onclick="showToolTip(this);"></asp:Label>                     
      </HeaderTemplate>
            <ItemTemplate>                                   
               <asp:Label id="lblPermitNumber" runat="server"></asp:Label>                  
             </ItemTemplate>
       </telerik:GridTemplateColumn>


    protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
    var item = e.Item as GridDataItem;
    TableCell documentColumn = item["TemplateColumnOne"];
    var lblPermitNumber=(Label)documentColumn.FindControl("lblPermitNumber");
     lblPermitNumber.Text = "some text;
    // how do you access LblToolTip ?
         }

I am able to change the values of all the controls in my telerik grid in the ItemDataBound method except those in the HeaderTemplate

How can I access those controls?

      <telerik:GridTemplateColumn UniqueName="TemplateColumnOne" >
      <HeaderStyle ></HeaderStyle>
      <HeaderTemplate >                                  
      <asp:Label ID="lblToolTip"  runat="server"  onclick="showToolTip(this);"></asp:Label>                     
      </HeaderTemplate>
            <ItemTemplate>                                   
               <asp:Label id="lblPermitNumber" runat="server"></asp:Label>                  
             </ItemTemplate>
       </telerik:GridTemplateColumn>


    protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
    var item = e.Item as GridDataItem;
    TableCell documentColumn = item["TemplateColumnOne"];
    var lblPermitNumber=(Label)documentColumn.FindControl("lblPermitNumber");
     lblPermitNumber.Text = "some text;
    // how do you access LblToolTip ?
         }

I am able to change the values of all the controls in my telerik grid in the ItemDataBound method except those in the HeaderTemplate

How can I access those controls?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 01 Feb 2016, 12:31 PM
Hello Perry,

You need to use the correct item:
if (e.Item is GridHeaderItem)

That should do the trick.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
perry
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or