locked
How do I use a repeater to only show content on a ASP page RRS feed

  • Question

  • User-657364217 posted

    I've got this code in a Fashion page to show a list of logos, for a page that im reusing for example Fashion as parent, Men, Women, Kids and Outdoor as the children inheriting the page design from the parent and with page id's.

    <div class="HomepageLogos">
    <asp:Literal runat="server" ID="Logos_Placeholder" />
    </div>

    Now I need to use a repeater functionality to only show the above code on Fashion page only and not on the children's pages

    Wednesday, May 22, 2019 6:45 AM

Answers

  • User-2054057000 posted

    Understand repeater as a control that repeats some thing over a certain time. Here you will have to repeat the logos in it. So you have to enter your literal control to show the logos inside the repeater. You could see any repeater code in the internet and build your own logic into it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2019 3:36 AM

All replies

  • User288213138 posted

    Hi  ldaless,


    According to your description, I couldn’t understand your requirement clearly.

    Do you mean you want to Use Literal in the repeater control?

    If this is your requirement, you can refer to the demo I wrote:

     The code:

    <asp:Repeater ID="Repeater1" runat="server">             
                    <ItemTemplate>                    
                            <asp:Literal ID="Literal1" runat="server" Text='<%#Eval("ID") %>'></asp:Literal>                          
                            <asp:Literal ID="Literal2" runat="server" Text='<%#Eval("Name") %>'></asp:Literal><br />                   
                    </ItemTemplate>
                </asp:Repeater>
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    
    protected void Page_Load(object sender, EventArgs e)
            {
                DataTable dt = new DataTable();
                dt.Columns.AddRange(new DataColumn[2] { new DataColumn("ID"), new DataColumn("Name") });
                dt.Rows.Add(1, "Sam1");
                dt.Rows.Add(2, "Sam2");
                dt.Rows.Add(3, "Sam3");
                Repeater1.DataSource = dt;
                Repeater1.DataBind();
               
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                foreach (RepeaterItem Item in Repeater1.Items)
                {
                    Literal l2 = (Literal)(Item.FindControl("Literal2"));
                    Response.Write(l2.Text);
    
                }                                   
            }
    

    If I misunderstand your requirement, please post more details information about your requirement.

    Best Regard,
    Sam

    Wednesday, May 22, 2019 10:06 AM
  • User-2054057000 posted

    Understand repeater as a control that repeats some thing over a certain time. Here you will have to repeat the logos in it. So you have to enter your literal control to show the logos inside the repeater. You could see any repeater code in the internet and build your own logic into it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2019 3:36 AM