Adam Lynch
Adam Lynch

Reputation: 3369

How do I add a span to asp:TemplateColumn th?

The Code:

<asp:TemplateColumn HeaderText="<%$ Resources:index, IndexSearch_Header_Product %>"
HeaderStyle-HorizontalAlign="Left" 
ItemStyle-HorizontalAlign="Left"> 

    <ItemTemplate> 
        <asp:HyperLink runat="server" ID="productLink" /> 
    </ItemTemplate> 
</asp:TemplateColumn>

I changed the header text to HeaderText="<span><%$ Resources:index, IndexSearch_Header_Product %></span>" and it gave me the span but just printed "<%$ Resources:index, IndexSearch_Header_Product %>" in it

Upvotes: 0

Views: 288

Answers (2)

MikeM
MikeM

Reputation: 27415

Remove this:

HeaderText="<%$ Resources:index, IndexSearch_Header_Product %>"

And add a <HeaderTemplate> like so:

<asp:TemplateColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left">
    <HeaderTemplate>
        <span><asp:Literal id="header" runat="server" Text="<%$ Resources:index, IndexSearch_Header_Product %>" /></span>
    </HeaderTemplate>
    <ItemTemplate> 
        <asp:HyperLink runat="server" ID="productLink" /> 
    </ItemTemplate>
</asp:TemplateColumn>

Upvotes: 1

Brian Mains
Brian Mains

Reputation: 50728

There should be a HeaderTemplate, which you can use to render the resource... You can use a Label and embed in the label text the resource string.

HTH.

Upvotes: 0

Related Questions