title: Second Dynamic DIV over writes first dynamic DIV
body: <p>I have searched for almost three days now and I can't find an answer to this question. As I am somewhat new to ASP.Net I am not sure what the problem is.
  Here is the situation. I have an aspx page that has a web form on it. When this form loads it has two SQL queries that execute and populate different controls.</p>
  
  <p>My problem lies not with the queries but creating dynamic DIV tags and adding controls to them. If the query returns one or no records everything is fine. but if there are 2 or more records returned I only end up with the last record being displayed.</p>
  
  <p>When I view the page source (from the browser) I can see the DIV tag ID that was created last, but the first DIV tag is gone. It is like the first DIV tag gets over written or something. I have no idea as to why or what is causing this.</p>
  
  <p>Can anyone help please?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    While (incCounter &lt;= rowCount)
          DivName.ID = ("rev" &amp; Convert.ToString(incCounter)) 'Create Div name of rev and the current counter number ex. rev1
          review_comments.Controls.Add(DivName) 'Add DIV to web form
          rName = (rName &amp; Convert.ToString(incCounter)) 'Create name control name
          rDate = (rDate &amp; Convert.ToString(incCounter)) 'Create date control name
          rComments = (rComments &amp; Convert.ToString(incCounter)) 'Create comment control name
          DivName.Controls.Add(New LiteralControl("&lt;br /&gt;"))
          DivName.Controls.Add(rRevByLabel)
          rNameTextBox.ID = rName
          DivName.Controls.Add(rNameTextBox)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(nbSpace)
          DivName.Controls.Add(rDateLabel)
          DivName.Controls.Add(rDateTextBox)
          DivName.Controls.Add(New LiteralControl("&lt;br /&gt;"))
          DivName.Controls.Add(rCommentLabel)
          DivName.Controls.Add(rCommentsTextBox)
          'Assign data from query to new textboxes
          rNameTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_name").ToString()
          rDateTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_date").Date()
          rCommentsTextBox.Text = dtR.Rows(incCounter - 1)("review_comments").ToString()
  
          rName = "revName"
          rDate = "rDate"
          rComments = "revComments"
          incCounter += 1
      End While
  </code></pre>
  
  <p>I know all the variables are set up correctly because it shows me the last record.</p>
  
  <p>What stupid thing am I doing?</p>