title: Add row to gridview in Visual Basic
body: <p>I have a gridview on my ASP website that needs to process each row and, based on a condition, either keep the row or remove it and add it to another gridview. I've figured out how to remove the row by simply using one of the built-in methods. Everything I find online is telling me to use the "gridview.Rows.Add(row)" property, however it creates the following error in Visual Studio:</p>
  
  <p>"'Add' is not a member of 'System.Web.UI.WebControls.GridViewRowCollection'."  </p>
  
  <ul>
  <li>grdTraining is the "master" gridview containing the results to be examined. </li>
  <li>grdExpTraining is the "secondary" gridview that takes the rows pulled from the "master."</li>
  <li><p>grdTraining_RowDataBound is a method that gets called everytime the website finds records to place into grdTraining. </p>
  
  <pre><code>Protected Sub grdTraining_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdTraining.RowDataBound
  
     ' Grey out expired training courses
     Dim row As GridViewRow
     row = e.Row
     Dim incomingDate As String
     incomingDate = row.Cells(4).Text.ToString()
  
     If (e.Row.RowType &lt;&gt; DataControlRowType.DataRow) Then
         Exit Sub
     End If
  
     Try
         Dim expDate As Date = incomingDate
         If (expDate &lt; DateTime.Today) Then
             grdExpTraining.Rows.Add(row)    'The line that is causing the error
             grdTraining.DeleteRow(trnIndex)
         End If
     Catch ex As Exception
     End Try
  
     trnIndex += 1
  End Sub
  </code></pre></li>
  </ul>