(高手请进!!)ASP 分行显示并且要隔行换背景色!

来源:百度知道 编辑:UC知道 时间:2024/06/22 18:17:53
我想实现一行分两列,并且想要隔行换一种背景颜色,可是在换背景颜色的时候老是不对,请高手帮忙看一下,指点一下!
代码如下:
<table>
<%
Sql="select * from Ent_info order by id desc"
Set Rs=Conn.ExeCute(Sql)
if not Rs.eof then
i=0
do while not Rs.eof
bt_str=trim(Rs("Ent_name"))
if i mod 2=0 then
color_sign="#ECF5FF"
else
color_sign=""
end if
if i=2 then
i=0
%>
<tr bgcolor="<%=color_sign%>">
<%end if%>
<td width="4%" height=20 class=a12><img src="image/mz_icontop.gif" width="25" height="15"></td>
<td width="45%" align=middle class=a12><p align="left"><%=bt_str%></p></td>
<%
Rs.movenext
i=i+1

<%
for i=1 to rs.pagesize
j=i
if j mod 2=0 then
bg="#ffffff"
else
bg="#cccccc"
end if
%>
<tr bgcolor=<%=bg%>>
<td>'你要循环显示的内容</td>
</tr>
<%
rs.movenext
if rs.eof then exit for
next
%>

do while not Rs.eof
bt_str=trim(Rs("Ent_name"))
'这里通过不同的i,来设置不同的color
if i mod 2=0 then
color_sign="#ECF5FF"
else
color_sign="#FF0000"
end if

%>
<tr bgcolor="<%=color_sign%>">
<%end if%>
<td width="4%" height=20 class=a12><img src="image/mz_icontop.gif" width="25" height="15"></td>
<td width="45%" align=middle class=a12><p align="left"><%=bt_str%></p></td>
<%
Rs.movenex