目的:封装成页面table,以字符串的形式返回给request

 '将查询的结果写到table中,用于popup显示


        Dim temptable As String = "<table border='0' cellpadding='0' cellspacing='1' style ='background-color:#C0FFFF;width:100%;'>"
’循环行数
        While Dr.Read()
‘循环列数


            For i As Integer = 0 To Dr.FieldCount - 1
                Dim value As String


                If System.Convert.IsDBNull(Dr.GetValue(i)) Then

                    value = "null"
                Else
‘取出该列的值
                    value = Dr.GetValue(i).ToString

                End If
                temptable = temptable + "<tr style='height:20px;'>"
’取出该列的列名字
                temptable = temptable + "<td width='150px' align='center' style ='background-  color:LightGoldenrodYellow'>" + Dr.GetName(i).ToString() + "</td>"
                temptable = temptable + "<td width='150px' align='center'>" + value + "</td>"
                temptable = temptable + "</tr>"
            Next

        End While
        Dr.Close()
        conn.Close()


        temptable += "<table>"

posted on 2008-03-15 12:25  Stym--闫生  阅读(383)  评论(0编辑  收藏  举报