I have the following code:
<tr id="test" runat="server">
<td align="<%=myalignment%>">
I set myalignment = “center”, however, when the page is rendered, it doesn’t grab the variable. It just shows exactly how it is above. I wanted to programatically change certain TDs to “center” or “left” and I thought this would work. Any ideas?
If tr doesn’t have runat=”server”, then it works fine…
Controls that run server-side can’t have properties set declaratively and resolved dynamically via the <%= %> (Response.Write) syntax.
Expressions can be used, or in a pinch, you can use <%# %> databinding syntax, but then you need to call DataBind() on the control or page, and that can have nasty side effects.
As an alternative, you should be able to iterate over cells or reference specific cells in the codefile. You might have to add the runat=server attribute to each cell as well — not sure about that.