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

ForeColor in the TilePeekTemplate

1 Answer 64 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Steve Gray
Top achievements
Rank 1
Steve Gray asked on 05 Sep 2016, 01:37 PM

Sirs:

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" >
    <DataBindings>
        <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>
 
            </div>
        </TilePeekTemplate>
 
    </DataBindings>
</telerik:RadTileList>       

 

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 07 Sep 2016, 08:15 AM

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));
}

<TilePeekTemplate>
    <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>
    </asp:Panel>
 
</TilePeekTemplate>

Regards,

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.
Tags
TileList
Asked by
Steve Gray
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or