asp下制做行背景顏色交替變換的表格
更新時(shí)間:2007年04月06日 00:00:00 作者:
<%
Const adInteger = 3
Const adVarChar = 200
' 聲明變量
Dim myRecordset
Dim iLetter
Dim Field
Dim strAltColor
Dim bColor
bColor = False
' 此例利用內(nèi)存中的recordset,你需要做的只是修改你的數(shù)據(jù)顯示的部分就可以了。
Set myRecordset = Server.CreateObject("ADODB.Recordset")
myRecordset.Fields.Append "ID", adInteger
myRecordset.Fields.Append "Title", adVarChar, 25
myRecordset.Fields.Append "Description", adVarChar, 255
myRecordset.Open
' Fill RS with sample data:
For iLetter = Asc("A") To Asc("M")
myRecordset.AddNew
myRecordset.Fields("ID").Value = iLetter - 64
myRecordset.Fields("Title").Value = "字母:" & Chr(iLetter)
myRecordset.Fields("Description").Value = "這里測試字母:" & Chr(iLetter) & "."
myRecordset.Update
Next 'iLetter
'移動到頭部開始位置,以便下面的循環(huán)開始.
myRecordset.MoveFirst
' 在表格中顯示數(shù)據(jù)
Response.Write "<table border=""0"" cellspacing=""0"" cellpadding=""3"">" & vbCrLf
'表頭
Response.Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset.Fields
Response.Write vbTab & vbTab & "<td bgcolor=""#CCCCCC""><strong>"
Response.Write Field.Name
Response.Write "</strong></td>" & vbCrLf
Next 'Field
Response.Write vbTab & "</tr>" & vbCrLf
Do While Not myRecordset.EOF
' 循環(huán)改變單元格的背景顏色
bColor = Not bColor
If bColor Then
strAltColor = "#FFFFFF"
Else
strAltColor = "#FF8040"
End If
'循環(huán)改變單元格的背景顏色
Response.Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset.Fields
Response.Write vbTab & vbTab & "<td bgcolor="""
Response.Write strAltColor
Response.Write """>" & Field.Value & "</td>" & vbCrLf
Next 'Field
Response.Write vbTab & "</tr>" & vbCrLf
myRecordset.MoveNext
Loop
' End the table
Response.Write "</table>" & vbCrLf
' 關(guān)閉對象、釋放資源
myRecordset.Close
Set myRecordset = Nothing
%>
Const adInteger = 3
Const adVarChar = 200
' 聲明變量
Dim myRecordset
Dim iLetter
Dim Field
Dim strAltColor
Dim bColor
bColor = False
' 此例利用內(nèi)存中的recordset,你需要做的只是修改你的數(shù)據(jù)顯示的部分就可以了。
Set myRecordset = Server.CreateObject("ADODB.Recordset")
myRecordset.Fields.Append "ID", adInteger
myRecordset.Fields.Append "Title", adVarChar, 25
myRecordset.Fields.Append "Description", adVarChar, 255
myRecordset.Open
' Fill RS with sample data:
For iLetter = Asc("A") To Asc("M")
myRecordset.AddNew
myRecordset.Fields("ID").Value = iLetter - 64
myRecordset.Fields("Title").Value = "字母:" & Chr(iLetter)
myRecordset.Fields("Description").Value = "這里測試字母:" & Chr(iLetter) & "."
myRecordset.Update
Next 'iLetter
'移動到頭部開始位置,以便下面的循環(huán)開始.
myRecordset.MoveFirst
' 在表格中顯示數(shù)據(jù)
Response.Write "<table border=""0"" cellspacing=""0"" cellpadding=""3"">" & vbCrLf
'表頭
Response.Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset.Fields
Response.Write vbTab & vbTab & "<td bgcolor=""#CCCCCC""><strong>"
Response.Write Field.Name
Response.Write "</strong></td>" & vbCrLf
Next 'Field
Response.Write vbTab & "</tr>" & vbCrLf
Do While Not myRecordset.EOF
' 循環(huán)改變單元格的背景顏色
bColor = Not bColor
If bColor Then
strAltColor = "#FFFFFF"
Else
strAltColor = "#FF8040"
End If
'循環(huán)改變單元格的背景顏色
Response.Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset.Fields
Response.Write vbTab & vbTab & "<td bgcolor="""
Response.Write strAltColor
Response.Write """>" & Field.Value & "</td>" & vbCrLf
Next 'Field
Response.Write vbTab & "</tr>" & vbCrLf
myRecordset.MoveNext
Loop
' End the table
Response.Write "</table>" & vbCrLf
' 關(guān)閉對象、釋放資源
myRecordset.Close
Set myRecordset = Nothing
%>
相關(guān)文章
Asp Conn.execute的參數(shù)與返回值總結(jié)
這篇文章主要介紹了Asp Conn.execute的參數(shù)與返回值總結(jié),數(shù)據(jù)庫對象的execute方法參數(shù)與返回值總結(jié),需要的朋友可以參考下2014-07-07Asp Split函數(shù)之使用多個(gè)分割符的方法
有時(shí)候用戶輸入的分隔符種類比較多,支持逗號也想要支持空格等等,其實(shí)原來就是先統(tǒng)一為一中分隔符再使用split進(jìn)行分割就可以了2013-03-03access改mdb為asp所帶來的災(zāi)難 附mdb防下載方法
可能是隨著網(wǎng)絡(luò)安全技術(shù)的發(fā)展吧,管理員的素質(zhì)都在提高,在使用access+asp系統(tǒng)時(shí),為不數(shù)據(jù)庫被人下載,到把mdb改為asp或asa。2010-05-05asp下用實(shí)現(xiàn)模板加載的的幾種方法總結(jié)
asp下html模板的加載方法,一般有以下幾種,大家可以根據(jù)情況自己決定,結(jié)果都是一樣的,都是好方法2008-01-01