How can you you add a span in a itemtemplate (code behind)

1.7k views Asked by At

I want to add a span with code behind to a itemTemple (inside a gridview)

<itemTemplate>
    // Here i want a span build up with code behind
    <asp:HyperLink ID="hyperlinkID" runat="server">#</asp:HyperLink>
</itemTemplate>

Is this even posible or do i need to declare a placeholder in the aspx.

1

There are 1 answers

2
Tim Schmelter On BEST ANSWER

A span which you want to access on serverside is a Label that is rendered as span later.

<ItemTemplate>
    <asp:Label ID="LblId" runat="server" Text='<%# Bind("TextColumn") %>'></asp:Label>
</ItemTemplate>

If you want to hide it under certain conditions i would use the RowDataBound-event. Visible=false on server-side means that it's not rendered at all on client-side.