Sub AutoCreatePropertysControls(ByVal obj As Object)
Dim p As PropertyInfo() = obj.GetType.GetProperties()

For Each pi In p
Dim lt As New Literal
lt.Text = "<li>"
ph.Controls.Add(lt)
Dim pty As String = pi.PropertyType.ToString
Dim lb As Label = New Label
lb.Text = pi.Name
ph.Controls.Add(lb)
lb.Dispose()
If (pi.PropertyType Is GetType(Boolean)) Then
Dim cb As New CheckBox
cb.ID = "tb_" & pi.Name
cb.Checked = pi.GetValue(obj, Nothing)
ph.Controls.Add(cb)
cb.Dispose()
Else
Dim tb As TextBox = New TextBox
tb.ID = "tb_" & pi.Name
tb.Text = pi.GetValue(obj, Nothing)
ph.Controls.Add(tb)
tb.Dispose()
End If

Dim lt2 As New Literal
lt2.Text = "</li>"

Next
End Sub

文字发表于: http://ysoho.cnblogs.com 作者Homepage:http://www.ysoho.com COPY 请保留 此声明

浙公网安备 33010602011771号