views:

19

answers:

1

I'm trying to set a property on a custom DropDownList:

<custom:ReferenceDropDownList ... ValidityDate="<%# Application.CreateDate %>" />

Even though I can see that Application.CreateDate has been set in the Page_Load method on the containing UserControl, the code-behind in the DDL never seems to pick it up.

protected override void OnLoad(EventArgs e)
{
    // this.ValidityDate is always null
}

This is even the case with ValidityDate="<%# DateTime.Now %>". The property of the DDL is declared like this:

[Category("Data")]
[DefaultValue(null)]
public DateTime? ValidityDate { get; set; } 

Does anyone know what is the correct sequence I should be following here. I thought that a DDL would evaluate a cynamic property value like that without too much trouble.

A: 

Make sure you DataBind() the page or control when using <# ... >.

Jordan
It is being databound alright, it's just not picking up the properties that have been dynamically set, as opposed to those like DataTextField="ShortName", for instance
Rafe Lavelle