开发者

Problem setting a property on an Asp.Net custom dropdownlist

开发者 https://www.devze.com 2023-01-21 18:54 出处:网络
I\'m trying to set a property on a custom DropDownList: <custom:ReferenceDropDownList ... ValidityDate=\"<%# Application.CreateDate %>\" />

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 <# ... >.

0

精彩评论

暂无评论...
验证码 换一张
取 消