title: VB.NET: Code does not check if control exists in panel
body: <p>My code :</p>
  
  <pre><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
  </code></pre>
  
  <p>But this always adds control to panel, the following code line is not executed correctly:
  <code>(If Not Panel.Controls.Contains(Label) Then)</code>  </p>
  
  <p>This code works in timer.</p>