My code :
Rs.Open("Select * From Notifications",Con)
If Not Rs.EOF Then
For i=0 to Rs.RecordCount -1
Dim Label As New Label
With Label
.Name = String.Format("Label_{0}",Rs("Id").Value.ToString)
.Text = Rs("Notification").Value.ToString
End With
If Not Panel.Controls.Contains(Label) Then
Panel.Control.Add(Label)
End If
Rs.MoveNext()
Next
End If
But this always adds control to panel, the following code line is not executed correctly:
(If Not Panel.Controls.Contains(Label) Then)
This code works in timer.
The above function is to check whether control(label) exists in Panel or not.