How to pass data from WebUserControl to a Page
<p>I have WebUserControl which made of 3 DropDownLists (day/month/year). It has public property DateTime BirthDate. I create this WebUserControl  dynamically on Page (Page_Load). I want to be able to change data in loaded WebUserControl and save it with button on Page.</p>

<p>WebUserControl code:</p>

<pre><code>public DateTime BirthDate { get; set; }

protected void Page_Load(object sender, EventArgs e)
{
    DropDownList dd = new DropDownList();
    DropDownList dm = new DropDownList();
    DropDownList dy = new DropDownList();

    this.Controls.Add(dd);
    this.Controls.Add(dm);
    this.Controls.Add(dy);

    dd.Items.Add(new ListItem("day","0"));
    dm.Items.Add(new ListItem("month", "0"));
    dy.Items.Add(new ListItem("year", "0"));

    dd.Items.AddRange(GetNumericValues(1, 31).ToArray());
    dm.Items.AddRange(GetNumericValues(1, 12).ToArray());
    int yearNow = DateTime.Now.Year;
    dy.Items.AddRange(GetNumericValues(yearNow - 100, yearNow - 17).ToArray());

    dd.DataBind();
    dm.DataBind();
    dy.DataBind();

    if (BirthDate != DateTime.MinValue)
    {
        dd.SelectedValue = BirthDate.Day.ToString();
        dm.SelectedValue = BirthDate.Month.ToString();
        dy.SelectedValue = BirthDate.Year.ToString();
    }
    else
    {                
        dd.SelectedValue = "0";
        dm.SelectedValue = "0";
        dy.SelectedValue = "0";
    }


}

private List&lt;ListItem&gt; GetNumericValues(int from, int to)
{
    List&lt;ListItem&gt; n = new List&lt;ListItem&gt;();
    for (int i = from; i &lt;= to; i++)
    {
        n.Add(new ListItem(i &lt; 10 ? "0" + i.ToString() : i.ToString()));
    }
    return n;
}
</code></pre>

<p>Page code:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        BirthDateWebUserControl bc = new BirthDateWebUserControl();
        PanelForm.Controls.Add(bc);
        ViewState["BirthDateWebUserControl"] = bc;
    }
}

protected void Button1_Click(object sender, EventArgs e)
{
    BirthDateWebUserControl bc = (BirthDateWebUserControl)ViewState["BirthDateWebUserControl"];
    LabelResult.Text = bc.BirthDate.ToString("dd/MM/yy");
}
</code></pre>

<p>What i'm doing wrong ?</p>

<p>thanks</p>
