Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:59:19+00:00 2026-06-10T22:59:19+00:00

I have a gridview on my ASP website that needs to process each row

  • 0

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:

“‘Add’ is not a member of ‘System.Web.UI.WebControls.GridViewRowCollection’.”

  • grdTraining is the “master” gridview containing the results to be examined.
  • grdExpTraining is the “secondary” gridview that takes the rows pulled from the “master.”
  • grdTraining_RowDataBound is a method that gets called everytime the website finds records to place into grdTraining.

    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 <> DataControlRowType.DataRow) Then
           Exit Sub
       End If
    
       Try
           Dim expDate As Date = incomingDate
           If (expDate < 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
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:59:21+00:00Added an answer on June 10, 2026 at 10:59 pm

    I was able to add a row to my grid view using the following code. I basically had to re-do the entire process again, treating the nested gridview like a completely new gridview. This also only works if you plan on placing one row in the nested gridview. You can play with the scope of the DataTable and DataRow declarations to do otherwise.

                'Create datatable and columns
                Dim dtable As New DataTable
                dtable.Columns.Add(New DataColumn("StateCode"))
                dtable.Columns.Add(New DataColumn("CourseDesc"))
                dtable.Columns.Add(New DataColumn("Hours"))
                dtable.Columns.Add(New DataColumn("EffectiveDate"))
                dtable.Columns.Add(New DataColumn("ExpirationDate"))
                dtable.Columns.Add(New DataColumn("LastChange"))
    
                'Create counter to prevent out of bounds exception
                Dim i As Integer = row.Cells.Count
    
                'Create object for RowValues
                Dim RowValues As Object() = {"", "", "", "", "", ""}
    
                'Fill row values appropriately
                For index As Integer = 0 To i - 1
                    RowValues(index) = row.Cells(index).Text
                Next
    
                'create new data row
                Dim dRow As DataRow
                dRow = dtable.Rows.Add(RowValues)
                dtable.AcceptChanges()
    
                'now bind datatable to gridview... 
                grdExpTraining.DataSource = dtable
                grdExpTraining.DataBind()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly big asp.net website that use GridView bound to the same
I have a ASP.NET Website, where, in a GridView item template, automatically populated by
I currently have an asp:GridView that displays a few BoundFields and then one asp:TemplateField
I have created a test website that contains a single ASP.net index.aspx file that
i'm creating a shopping website. i have a gridview that is bound to an
I am working on an ASP.Net website and have a GridView displaying some data,in
I have GridView with CheckBox in it's header and another one in each row:
I want to have an ASP C# WebSite that loads a simple CSV File
I have a ASP.NET/VB that had a GridView to display a list of users
I have a gridview in ASP.net 2.0 that has a small peace of javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.