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

Using c# method in column header of gridview

2 Answers 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
guillaume monore
Top achievements
Rank 1
guillaume monore asked on 21 Apr 2011, 05:16 PM

Hello !

i would like to do the same think the is working:

 

 

 

 

<asp:Label CssClass="edInline" ID="LblActif" Width="115px" runat="server"><%= DatabaseResourceManager.Translate("5031/Actif")%></asp:Label>

 

 

 

 

i m calling a c# class to translate my text with the database text corresponding in the good language and it works good, i would like to do the same with columns in the aspx file not in code behind but this doesn't seems to work :

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="LastName" FilterControlAltText="Filter column column"
  
HeaderText='<%= DatabaseResourceManager.Translate("5914/:Nom")%>' UniqueName="LastName">
  
</telerik:GridBoundColumn>

 

some help ?

[EDIT]
Ok I found a way to solve it (the night is good to think :-) )

<telerik:GridTemplateColumn>
     <HeaderTemplate>
           <asp:Label ID="clLblLastName" runat="server"><%= DatabaseResourceManager.Translate("5914/Nom") %></asp:Label
      </HeaderTemplate>
      <ItemTemplate>
            <asp:Label runat="server" ID="clTxtLastName" Text='<%# Eval("LastName") %>'></asp:Label>
       </ItemTemplate>
</telerik:GridTemplateColumn>

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 27 Apr 2011, 12:20 PM
Hello Guillaume,

I am glad that you achieved the desired functionality. the other way to achieve the desired functionality is to change the column's header text from code behind on RadGrid1_ItemDataBound
event handler. For example:
void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
  {
      if (e.Item is GridHeaderItem)
      {
          GridHeaderItem item = e.Item as GridHeaderItem;
          item["ColumnUniqueName"].Text = getHeaderText();
      }
  }
 
  public string getHeaderText()
  {
      return "Header Text";
  }

In case you experience any further problems, do not hesitate to contact us again.

Kind regards,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
guillaume monore
Top achievements
Rank 1
answered on 27 Apr 2011, 04:18 PM
Thx for the reply, but i had to do this without using Code behind :-).
Tags
General Discussions
Asked by
guillaume monore
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
guillaume monore
Top achievements
Rank 1
Share this question
or