ใช้การ Create Control แล้ว Add Control เข้าไปใน Control อีกทีครับ
Code (VB.NET)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'*** Create New Label ***'
Dim lblText As New Label
With lblText
.Text = "My Customer"
.Font.Size = "30"
End With
Me.pnlMain1.Controls.Add(lblText)
'*** Create DataGrid ***'
Dim myDataGrid As New DataGrid
With myDataGrid
.AutoGenerateColumns = True
.DataSource = DataSource()
.DataBind()
End With
Me.pnlMain2.Controls.Add(myDataGrid)
End Sub