多行多列的显示函数~

来源:互联网 发布:嵌入式软件开发环境 编辑:程序博客网 时间:2024/05/19 05:02
关键在于计算要填充多少,有多少数据
对于没有填充的部分,需要用空格来填充。


需要使用Open sql, conn的方式获得数据集,以便得到recordcount参数

<table border="1" cellspacing="0" cellpadding="0">
<tr>
<%
Dim i '常规变量
Dim iNum '单元格总数
Dim iCol '列数
iCol = 10
iNum = CInt(oRs.RecordCount/iCol)*iCol
For i = 1 To iNum
%>
<td>
<%
If IsNull(oRs("字段")) Or oRs("字段")="" Then
Response.Write "&nbsp;"
Else
Response.Write oRs("字段")
End If
%>
</td>
<%
If (i Mod iCol)=0 Then
Response.Write("</tr>")
End If
oRs.MoveNext
Next
%>
</table