我有这种形式从SQL表中创建的代码背后:如何使用StringBuilder加入控件?
Dim holder As PlaceHolder = CType(FV.FindControl("plControl"), PlaceHolder)
Dim html As New StringBuilder()
html.Append("<table>")
For Each Row As DataRow In ds.Tables(0).Rows
html.Append("<tr style='border: 1px solid black; height:30px;'>")
html.Append("<td style='padding-right:40px; width:400px; text-align:right; background-color:lightgray;border: 1px solid black;'><b>")
html.Append(Row(columnName:="Name"))
html.Append("</b></td>")
html.Append("<td style='width:300px; text-align:center; background-color:lightgray;border: 1px solid black;'>")
html.Append("</td>")
html.Append("<td style='width:300px; text-align:center; background-color:lightgray;border: 1px solid black;'>")
html.Append("</td>")
html.Append("</tr>")
Next
html.Append("</table>")
holder.Controls.Add(New Literal() With { _
.Text = html.ToString() _
})
现在,在这个表我想添加和控制但每次控制在StringBuilder的加入将被识别为一个HTML文本。
我在循环中使用这样的:
Dim btn As New Button
btn.Text = "Click me.."
AddHandler btn.Click, AddressOf MyButton_Click
MyPlaceHolder.Controls.Add(btn)
但这种控制将在我的桌子的顶部添加。我只想知道有没有什么方法可以在此表中添加Controls?