ForeColor in the TilePeekTemplate

2 posts, 0 answers
  1. steve gray
    steve gray avatar
    17 posts
    Member since:
    Mar 2006

    Posted 05 Sep 2016 Link to this post


    I'm trying to dynamically set the font color in the TileList PeekTemplate. The code that I'm using is below (and it works), but Visual Studio generates 7 warning for the syntax. Is there a better way? I can't seem to access that property in the TileDataBound event.

    <telerik:RadTileList runat="server" ID="RadTileList1" TileRows="1" >
            <CommonTileBinding  TileType="RadTextTile" DataNavigateUrlField="NavigateUrl"  />
            <TextTileBinding  DataTextField="Module_Name"    />
            <TilePeekTemplate  >
                <div style="font-size:20px; width:150px;color:<%# DataBinder.Eval(Container.DataItem, "TileColor") %>">
                    <div><%# DataBinder.Eval(Container.DataItem, "ModuleID") %></div>
                    <div style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "NumberOfTables") %></div>



  2. Marin Bratanov
    Marin Bratanov avatar
    5240 posts

    Posted 07 Sep 2016 Link to this post

    Hi Steve,

    There shouldn't be an issue with this approach. Nevertheless, you can consider using CSS classes for the desired colors if there is a limited number of values instead of the inline style attribute.

    As for doing that in the TileDataBound event—the styles collection of a server control can be used, or a Panel's properties. For example:

    protected void RadTileList1_TileDataBound(object sender, TileListEventArgs e)
        Panel pnl = e.Tile.PeekContentContainer.FindControl("Panel1") as Panel;
        pnl.ForeColor = Color.FromName(DataBinder.GetPropertyValue(e.Tile.DataItem, "TileColor", null));

        <asp:Panel ID="Panel1" runat="server" Font-Size="20px" Width="150px">
            <div><%# DataBinder.Eval(Container.DataItem, "ModuleID") %></div>
            <div style="font-size: 14px"><%# DataBinder.Eval(Container.DataItem, "NumberOfTables") %></div>


    Marin Bratanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top