views:

508

answers:

3

how do i implement an eval script in a sever side control?

eg. <a runat="server" href="?id=<%= Eval("Id") %>">hello world</a>

+1  A: 

<%# Eval("Id") %>

as far as I know, its <%# instead of <%=

Robinb
+1  A: 

The Data-Binding expression is your friend, see MSDN for examples.

snomag
+2  A: 

If the server-side control is within a databound control (ListView, GridView, FormView, DetailsView), then the syntax is: <%# Eval("Id") %>.

If the server-side control is not within a databound control, you will have to access it via the code-behind and set your attribute there.

Forgotten Semicolon