开发者

Changes HTML attr with inline scripting

开发者 https://www.devze.com 2022-12-13 19:10 出处:网络
I was trying to do this : <asp:GridView ID=\"gvBugList\" runat=\"server\" AutoGenerateColumns=\"False\" ShowHeader=\"False\"

I was trying to do this :

  <asp:GridView ID="gvBugList" runat="server" AutoGenerateColumns="False" ShowHeader="False"
   开发者_如何学C   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.


Inside your style attribute you need to put the following:

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

精彩评论

暂无评论...
验证码 换一张
取 消