1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Tables and repeaters

Tables and repeaters

2 posts, 0 answered
  1. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    25 Mar 2010
    Link to this post
    Hi I have a masterpage that looks like this

    <form id="form1" runat="server">
    <table cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td>Heading</td>
        </tr>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
    </table>
    </form>

    I want to place a user control in ContentPlaceHolder1 that inserts markup from a repeater in the form of <tr><td>content</td></tr>. 

    Control looks like this:
    <asp:Repeater ID="rptTest2" runat="server" Visible="false">
        <HeaderTemplate><ul></HeaderTemplate>
        <ItemTemplate><li>content</li></ItemTemplate>
        <FooterTemplate></ul></FooterTemplate>
    </asp:Repeater>
    <asp:Repeater ID="rptTest" runat="server" Visible="false" OnItemDataBound="rptTest_ItemDataBound">
        <HeaderTemplate></HeaderTemplate>
        <ItemTemplate><tr><td><asp:Literal ID="litTest" runat="server"></asp:Literal></td></tr></ItemTemplate>
        <FooterTemplate></FooterTemplate>
    </asp:Repeater>

    And code behind:

    protected void Page_Load(object sender, EventArgs e)
    {
        rptTest.Visible = true;
        BindNews();
    }
     
    protected void rptTest_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Literal litTest = (Literal)e.Item.FindControl("litTest");
            litTest.Text = "test";
        }
    }
     
    private void BindNews()
    {
        // create new instance of NewsManager
        NewsManager newsManager = new NewsManager("News");
        // get all news content items
        IList listOfNewsItems = newsManager.Content.GetContent();
        rptTest.DataSource = listOfNewsItems;
        rptTest.DataBind();
    }


    When I place the control in ContentPlaceHolder1 I cannot edit it.  Can someone please help?

    Thanks,
    Devin
  2. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    25 Mar 2010
    Link to this post
    I solved it!  It seems that removing rptTest2 from the user control resolves the issue.

    Thanks,
    Devin
2 posts, 0 answered