user310291
user310291

Reputation: 38190

why asp.net binding expression shows nothing

I'm just testing a simple databind expression with:

<div>
Now: <%# DateTime.Now.ToString()%>
</div>

According to MSDN: http://msdn.microsoft.com/en-us/library/bda9bbfx(VS.71).aspx

literal text <%# data-binding expression %>

should work.

When I compile, it's OK but I got a blank instead of Now DateTime.

What's wrong ?

Upvotes: 0

Views: 184

Answers (1)

AMissico
AMissico

Reputation: 21684

You must call a DataBind method. In this case, add a call to the Page.DataBind in the page's load event. The DataBind method is not called automatically. You must call it for the page or for specific controls.

ASP.NET data binding overview at http://support.microsoft.com/kb/307860

Upvotes: 4

Related Questions