当前位置:编程学习 > C#/ASP.NET >>

JS获取repeater列数据对比,小于则颜色为红色

前台标签
<table  class="tablelist" width="100%" border="0" cellspacing="0" cellpadding="0" id="demoTable">
              <thead>
                  <tr>                  
                    <th scope="col" order="totalje" width="90px" nowrap>总金额</th>
                    <th scope="col" width="90px"nowrap >应收款</th>
                    <th scope="col" width="90px" nowrap>实收款</th>
                    <th scope="col" width="90px" nowrap>剩余款</th>
                    <th width="30px" nowrap><%=Resources.UI.BtnEdit%></th>       
                </tr>
              </thead>                
                 <tbody id="mainbody">
                     <asp:Repeater ID="rptList" runat="server"  EnableViewState="false">
                      <ItemTemplate>
                        <tr >
                            <td style="text-align:right"><%#(Container.DataItem as View_CompactCustomer).totalje.ToString("n2")%></td>
                            <%#ShowCompactJE(Eval("ID"))%>                         </tr>
                      </ItemTemplate>    
                      <FooterTemplate>
                                       <td colspan="5">本页合计</td>
                         <td  style="text-align:right"><%=totalje.ToString("n2")%></td>
                         <%#ShowCompactJE2()%>
                      </FooterTemplate>    
                      </FooterTemplate>                           
                  </asp:Repeater>
                  
                  <asp:Repeater ID="rptTotal" runat="server"  EnableViewState="false">
               
                      <ItemTemplate>
                      <tr >
                           <td colspan="5">总计</td>
                            <td  style="text-align:right"><%#ShowMoney(Eval("总金额"))%></td>
                            <%#ShowCompactJE3()%>
                            <td width="20px"></td>
                      </tr>
                      </ItemTemplate>
                  </asp:Repeater>            
                 </tbody>   
            </table>
后台代码ShowCompactJE2
方法:  public string ShowCompactJE(object id){
 DataTable dt = new View_htkxService().QueryInstance.GetDataTable("exec proc_htkx_CompactID " + id.ToString() + ",'" + hkstart + "'," + "'" + hkend + "'" + ",'" + ssstart + "'," + "'" + ssend + "'," + "'" + fpstart + "'," + "'" + fpend + "'" + ",'" + qdstart + "'," + "'" + qdend + "'," + "'" + qs + "'," + "'" + servicetype + "'");
    
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                if (Cyberway.Common.Data.DAOCommon.DataTableHasRow(dt))
                {
                    if (i == 0)
                    {
                        try
                        {
                               ret = ret + "<td style='text-align:right'><a href=# onclick=\"OpenWindow('../Compact/CompactEdit4.aspx?action=edit&id=" + id.ToString() + "',650,400,false);return false;\">" + double.Parse(dt.Rows[0][i].ToString()).ToString("n2") + "</a></td>";
                            
                        }
                        catch (Exception ex)
                        {
                            ret = ret + "<td style='text-align:right'><a href=# onclick=\"OpenWindow('../Compact/CompactEdit4.aspx?action=edit&id=" + id.ToString() + "',650,400,false);return false;\">" + dt.Rows[0][i].ToString() + "</a></td>";

                        }
                       
                    }
                    else
                    {
                        if (i == 1)
                        {
                            try
                            {
                                ret = ret + "<td style='text-align:right'><a href=# onclick=\"OpenWindow('../Compact/CompactEdit5.aspx?action=edit&id=" + id.ToString() + "',650,400,false);return false;\">" + double.Parse(dt.Rows[0][i].ToString()).ToString("n2") + "</a></td>";
                            }
                            catch (Exception ex)
                            {
                                ret = ret + "<td style='text-align:right'><a href=# onclick=\"OpenWindow('../Compact/CompactEdit5.aspx?action=edit&id=" + id.ToString() + "',650,400,false);return false;\">" + dt.Rows[0][i].ToString() + "</a></td>";

                            }
                        }
                        else
                        {
                            try
                            {
                                ret = ret + "<td style='text-align:right'>" + double.Parse(dt.Rows[0][i].ToString()).ToString("n2") + "</td>";
                            }
                            catch (Exception ex)
                            {
                                ret = ret + "<td style='text-align:right'>" + dt.Rows[0][i].ToString() + "</td>";
                            }
                        }
                    }
                    try
                    {
                        total[0, i] = total[0, i] + double.Parse(dt.Rows[0][i].ToString());
                    }
                    catch (Exception ex)
                    { }
                }
                else
                {
                    ret = ret + "<td>" + "</td>";
                }
            }

        }
        ret = ret + "</td>";
        return ret;
    }
Q:如何获取总金额,与  <%#ShowCompactJE2()%>
获得的4列数据中的其中一列应收款对比,如应收款小于则显示红色。不知道能否用JS实现..?? --------------------编程问答-------------------- 偶滴神啊,这代码太强悍了,帮顶  
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,