R – Eval scripts in server side control property

asp.netcontrolseval

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

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

Best Solution

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.