着色动态创建的表行没有Javascript

时间:2014-02-06 03:46:18

标签: asp.net vb.net row border dynamic-controls

 Dim table1 As New HtmlTable
 Table1.Border = "1"
 Table1.BorderColor = "Blue"
        For j As Integer = 0 To 2
            Dim row As New HtmlTableRow()
            Dim cell1 As New HtmlTableCell()
            Dim cell2 As New HtmlTableCell()
            Dim rbl As New RadioButtonList()
            For RowIndex As Integer = 0 To 2
                rbl.ID = RowIndex
                rbl.Items.Add("Hi")
                Dim lbl1 As New Label()
                lbl1.ID = "Hi" + RowIndex.ToString
                lbl1.Text = "hello"
                lbl1.Height = "25"
                cell2.Controls.Add(lbl1)

                cell2.Controls.Add(new LiteralControl("<br />"))
            Next
            cell1.Controls.Add(rbl)
            row.Cells.Add(cell1)
            row.Cells.Add(cell2)
            table1.Rows.Add(row)
        Next
        PlaceHolder1.Controls.Add(table1)

在上面的代码中,边框和单元格以及整个表格都显示边框,但我需要的是边框应该出现在仅行而不是单元格中。

修改 添加此行时,行颜色正常工作

row.Attributes.Add("style", "outline: thin solid blue;")

但是在表格内双击的行显示.. !!

1 个答案:

答案 0 :(得分:2)

您可以尝试行的Outline样式。

您需要使用attributes.add()方法添加它。

删除Table1

的边框设置

请参阅完整代码,如下所示:

Dim table1 As New HtmlTable
        'table1.Border = "1"
        'table1.BorderColor = "Blue"
        For j As Integer = 0 To 2
            Dim row As New HtmlTableRow()
            Dim cell1 As New HtmlTableCell()
            Dim cell2 As New HtmlTableCell()
            Dim rbl As New RadioButtonList()

            row.Attributes.Add("style", "outline: thin solid blue;")
            For RowIndex As Integer = 0 To 2
                rbl.ID = RowIndex
                rbl.Items.Add("Hi")
                Dim lbl1 As New Label()
                lbl1.ID = "Hi" + RowIndex.ToString
                lbl1.Text = "hello"
                lbl1.Height = "25"
                cell2.Controls.Add(lbl1)

                'Add This
                cell2.Controls.Add(New LiteralControl("<br />"))
            Next
            cell1.Controls.Add(rbl)
            row.Cells.Add(cell1)
            row.Cells.Add(cell2)
            table1.Rows.Add(row)
        Next
        PlaceHolder1.Controls.Add(table1)