Changes HTML attr with inline scripting

65 views Asked by At

I was trying to do this :

  <asp:GridView ID="gvBugList" runat="server" AutoGenerateColumns="False" ShowHeader="False"
      DataSourceID="linqDSBugList" Width="100%" AllowPaging="true" PageSize="20" DataKeyNames="BugID">
      <Columns>
        <asp:TemplateField>
          <ItemTemplate>
            <div class="messageHeader" id='<%# String.Format("Message_{0}",Eval("BugID")) %>' style='<% if(Eval("Status") == true) return "background:green";%>'>
              <a href="#" onclick="BuggyBag.openMesage(this)">
                <%#Eval("Subject") %></a>
            </div>
            <div class="messageCollapse">
              <b>Message :</b><p>
                <%# Eval("Message") %>
              </p>
              <input type="button" onclick="BuggyBag.SetStatus(this,true)" value="Set Resolved"
                id='<%#Eval("BugID") %>' />
            </div>
          </ItemTemplate>
        </asp:TemplateField>
  </Columns>
</asp:GridView>

In this code I want to change messageHeader style properties according to Status field whose data coming from database. How can I do that with inline scripting. As you may see I tried to do that at style attr of messageHeader but it wouldn't work out.

Thanks.

1

There are 1 answers

4
Darko On BEST ANSWER

Inside your style attribute you need to put the following:

<%= ((bool)Eval("Status")) ? "background:green" : "" %>