No! you can't use <%= %> (expression) with server controls.
Use Binding expression:
Markup:
<asp:Label ID="Label1" runat="server" Text='<%# Session["value"] %>' />
Code-behind
protected void Page_Load(object sender, EventArgs e)
{
Session["value"] = 100;
Label1.DataBind();
}
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
>I didn't realise you could call DataBind expressions on controls without a DataSource assigned.
Actually, you have assigned a single value as an "expression"; it is also known as simple data binding .
You must have to call DataBind() method in order to evaluate <%# Eval("expression") %> .
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241