views:

10

answers:

0

I created a userControl "MyControl". I want that the Repeater consists it.

Repeater code

<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
   <mc:MyControl ID="myControl" runat="server" />
</ItemTemplate>
</asp:Repeater>

MyControl consists Button. Code:

public partial class MyControl : System.Web.UI.UserControl
{
    public String ButtonText { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Text = ButtonText;
    }

}

There is the method in default page.

protected void Page_Load(object sender, EventArgs e)
    {
        MyControl[] a = new MyControl[2];
        a[0] = new MyControl { ButtonText = "1" };
        a[1] = new MyControl { ButtonText = "2" };
        Repeater1.DataSource = a;
        Repeater1.DataBind();
    }

Why it doesn't work?