Note that there are some explanatory texts on larger screens.

plurals
  1. POtd style in repeater won't output bound value ("This is not a scriptlet. Will output as plain text")
    primarykey
    data
    text
    <p>I have a repeater with a table in it with lots of properties of the td's bound by the repeater. I have had to add a runat server to each td so I can add a visible attribute, because depending on the data some tds aren't visible.</p> <p>Now I have added the runat server I am having a problem setting the background colour of my tds. It is done with a bound value. When I add my &lt;%%> tags to my style they are output as plain text, It even says in my html that "This is not a scriptlet. Will output as plain text" where as the rest of my &lt;%%> tags bind correctly. </p> <p>Why won't my style bind anymore?</p> <p>Other tags I add will, but just not style?</p> <p>Here's a cut down version of my repeater.</p> <pre><code> &lt;table id="Table1" border="1" cellpadding="0" cellspacing="0" class="groups"&gt; &lt;tr id="Tr1" class="thead"&gt; &lt;td colspan='&lt;%#AllowedItems.Count() %&gt;' align="center"&gt; items &lt;/td&gt; &lt;/tr&gt; &lt;tr class="theadL"&gt; &lt;td id="Td1" runat="server" visible='&lt;%#ItemAllowed("Item1")%&gt;'&gt; item1 &lt;/td&gt; &lt;td id="Td2" runat="server" visible='&lt;%#ItemAllowed("Item2")%&gt;'&gt; item2 &lt;/td&gt; &lt;td id="Td3" runat="server" visible='&lt;%#ItemAllowed("Item3")%&gt;'&gt; item 3 &lt;/td&gt; &lt;/tr&gt; &lt;asp:Repeater ID="Repeater1" runat="server" DataSource='&lt;%# GetData((int)Eval("Id"))%&gt;'&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td id="Td9" title='&lt;%#Eval("Item1Status")%&gt;' runat="server" visible='&lt;%#ItemAllowed("Item1")%&gt;' style='background-color: &lt;%#Eval("Item1StatusColour")%&gt;;'&gt; &lt;/td&gt; &lt;td id="Td10" title='&lt;%#Eval("Item2Status")%&gt;' runat="server" visible='&lt;%#ItemAllowed("Item3")%&gt;' style='background-color: &lt;%#Eval("Item3StatusColour")%&gt;;'&gt; &lt;/td&gt; &lt;td id="Td11" title='&lt;%#Eval("Item3Status")%&gt;' runat="server" visible='&lt;%#ItemAllowed("Item4")%&gt;' style='background-color: &lt;%#Eval("Item4StatusColour")%&gt;;'&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p><strong>Update</strong></p> <p>The style renders like this :</p> <pre><code> style="background-color:&amp;lt;%# &amp;quot;&amp;quot;+ Eval(&amp;quot;Item1StatusColour&amp;quot;)%&gt;;" </code></pre> <p>All the rest of the attribute render how they should.</p> <p><strong>Update</strong> This is the ItemAllowed method as requested</p> <pre><code> public bool ItemAllowed(string item) { //allowed items is a list&lt;string&gt; return AllowedItems.Contains(item); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload