Problem setting a property on an Asp.Net custom dropdownlist
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.
Make sure you DataBind()
the page or control when using <# ... >
.
精彩评论