Repeater with Tiles

5 posts, 1 answers
  1. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 03 Nov 2013 Link to this post

    I am trying to use a RadContentTemplateTile in an asp:Repeater but the bindings are blank?  Any ideas?

    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                    <ItemTemplate>
                        <telerik:RadContentTemplateTile ID="RadContentTemplateTile1" runat="server"
                            Skin="Telerik">
                            <ContentTemplate>
                                <div>
                                    Name:<%# Eval("Name")%>
                                </div>
     
                            </ContentTemplate>
                            <PeekTemplate>
                                <div>
                                    peek here
                                    <telerik:RadButton ID="RadButton2" runat="server" Text="RadButton"></telerik:RadButton>
                                </div>
                            </PeekTemplate>
                            <PeekTemplateSettings Animation="Slide" ShowPeekTemplateOnMouseOver="true" HidePeekTemplateOnMouseOut="true" />
                        </telerik:RadContentTemplateTile>
                    </ItemTemplate>
     
                </asp:Repeater>


    Marty

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2013 Link to this post

    Hi Marty,

    You must use the <DataBindings> tag to data bind the RadTile. Please have a look into the following sample code I tried for your scenario.

    ASPX:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT top 4 [CustomerID], [ContactName] FROM [Customers]">
    </asp:SqlDataSource>
    <telerik:RadTileList runat="server" DataSourceID="SqlDataSource1" ID="RadTileList1"
        OnTileCreated="RadTileList1_TileCreated">
        <DataBindings>
            <CommonTileBinding TileType="RadContentTemplateTile" />
            <ContentTemplateTileBinding>
                <ContentTemplate>
                    <div style="padding-top: 45px">
                        <strong>CustomerID:</strong>
                        <%#DataBinder.Eval(Container.DataItem, "CustomerID")%>
                        <br />
                        <strong>ContactName:</strong>
                        <%#DataBinder.Eval(Container.DataItem, "ContactName")%>
                    </div>
                </ContentTemplate>
            </ContentTemplateTileBinding>
            <TilePeekTemplate>
                <div>
                    peek here
                    <telerik:RadButton ID="RadButton2" runat="server" Text="RadButton">
                    </telerik:RadButton>
                </div>
            </TilePeekTemplate>
        </DataBindings>
    </telerik:RadTileList>

    C#:
    protected void RadTileList1_TileCreated(object sender, Telerik.Web.UI.TileListEventArgs e)
    {
        e.Tile.PeekTemplateSettings.ShowInterval = 0;
        e.Tile.PeekTemplateSettings.CloseDelay = 0;
        e.Tile.PeekTemplateSettings.ShowPeekTemplateOnMouseOver = true;
        e.Tile.PeekTemplateSettings.HidePeekTemplateOnMouseOut = true;
        e.Tile.PeekTemplateSettings.AnimationDuration = 800;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 04 Nov 2013 Link to this post

    Shinu,

    Thanks, but I don't want a tilelist.  I just want to use the Tiles standalone in a repeater. Get the benefit of peek templates.

    Marty

  5. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 04 Nov 2013 Link to this post

    Hello Marty,

    Indeed, databinding expressions are not evaluated in this case. I am logging this for improvement and I have also updated your Telerik points for your report.

    In the meantime I can suggest the following workaround:
    protected void Repeater1_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RadContentTemplateTile tile = e.Item.FindControl("RadContentTemplateTile1") as RadContentTemplateTile;
        if(tile != null)
        {
            Label literal = tile.ContentContainer.FindControl("Label1") as Label;
            if(literal != null)
            {
                literal.Text = (e.Item.DataItem as DataRowView)["Name"].ToString();
            }
        }
    }

    <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_OnItemDataBound">
        <ItemTemplate>
            <telerik:RadContentTemplateTile ID="RadContentTemplateTile1" runat="server" Skin="Telerik">
                <ContentTemplate>
                    <div>
                        Name: <asp:Label ID="Label1" Text="" runat="server" />
                    </div>
                </ContentTemplate>
                <PeekTemplate>
                    <div>
                        peek here
                        <telerik:RadButton ID="RadButton2" runat="server" Text="RadButton">
                        </telerik:RadButton>
                    </div>
                </PeekTemplate>
                <PeekTemplateSettings Animation="Slide" ShowPeekTemplateOnMouseOver="true" HidePeekTemplateOnMouseOut="true" />
            </telerik:RadContentTemplateTile>
        </ItemTemplate>
    </asp:Repeater>


    Regards,
    Marin Bratanov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 04 Nov 2013 Link to this post

    Marin,

    Thanks.  I figured this was the direction I needed to go but did not know where to start.

    Marty
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017