Hi Nick,
As Mark and Milosz suggested, you need to declare the variable in aspx
inline server-code block (<script runat="server" >....</script>) or in the
codebehind page class so that the databinding express scope(in <%# %> )
can correctly reference that variable.
Also, for <% %> code block they're in different scope from <%# %>
databinding expression. For <%# %> databinding expression, it can
reference those variables that are defined in databinding container object
or in super level object(such as the page instance).
BTW, <%= %> block can not be used to initialize ASP.NET server control
properties, however, in ASP.NET 2.0 , you can build custom expression
builder to do this:
#From the Suggestion Box: Why can't you use code expressions for properties?
http://weblogs.asp.net/leftslipper/archive/2007/01/16/Using-code-expressions
-in-properties.aspx
If you have anything else unclear, please feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.