views:

23

answers:

0

Hi,

I have a class which extends from repeater class. Basically I need a custom repeater which should have this layout:

       <HeaderTemplate>

        </HeaderTemplate>

        <MyTemplate>

         </MyTemplate>

        <ItemTemplate>

        </ItemTemplate>

     <FooterTemplate>

    </FooterTemplate>

Till now I have written this code to achieve the same:



using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;


public class MyRepeater : Repeater
{
    [DefaultValue((string)null), PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(RepeaterItem)), Browsable(false)]
    public virtual ITemplate MyTemplate
    {
        get;
        set;
    }

    protected override void OnItemCreated(RepeaterItemEventArgs e)
    {
        base.OnItemCreated(e);
        if (e.Item.ItemType == ListItemType.Header)
        {
            var item = new RepeaterItem(1, ListItemType.Header);
            MyTemplate.InstantiateIn(item);
            item.DataItem = e.Item.DataItem;
            this.Controls.Add(item);
            item.DataBind();
        }
    }

}



But this code is giving me this layout:

 

        <MyTemplate>

        </MyTemplate>

      <HeaderTemplate>

        </HeaderTemplate>

        <ItemTemplate>

        </ItemTemplate>

        <FooterTemplate>

        </FooterTemplate>

i.e I am always getting my custom template above the header template, is this possible for me to have mytemplate just below the header template ?