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

  • Home
  • SEARCH
  • 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 8501903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:20:24+00:00 2026-06-11T01:20:24+00:00

Below is a loop I am trying to use to get the values from

  • 0

Below is a loop I am trying to use to get the values from a GridViewRow into a DataRow object (using the godforsaken language of Visual Basic). However, on this line:

                dr(i) = r.Cells(i).Text

I keep getting the following error message:

the value of type string cannot be converted to system.data.datarow

Can someone point me in the right direction on how to do this?

        Dim rows As New List(Of GridViewRow)()

        For Each item As GridViewRow In grdExpProd.Rows
            rows.Add(item)
        Next

        Dim value As Integer = rows.Count

        Dim dt As New DataTable()


        For index As Integer = value - 1 To 0 Step -1
            Dim dr As DataRow()
            Dim r As GridViewRow = rows(index)

            For i As Integer = 0 To r.Cells.Count - 1
                dr(i) = r.Cells(i).Text
            Next

            dt.Rows.Add(dr)
        Next
  • 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-11T01:20:26+00:00Added an answer on June 11, 2026 at 1:20 am

    I believe you need to be adding your text to the DataRows Item Property which will allow you access to the individual cells of the DataRow. You are also going to need to add the columns that exist in your GridRowView to your new DataTable.

    For i = 1 To rows(0).Cells.Count
        dt.Columns.Add("Header" & i)
    Next
    
    For index As Integer = value - 1 To 0 Step -1
        Dim dr As DataRow = dt.NewRow()
        Dim r As GridViewRow = rows(index)
    
        For i As Integer = 0 To r.Cells.Count 
            dr.Item(i) = r.Cells(i).Text
        Next
    
        dt.Rows.Add(dr)
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the data from input xml message using functoids. But
In the code below, I am trying to use a for loop to initialise
I am trying to loop these variables below (item_name, quantity and amount) @using (Html.BeginForm(PostToPaypal,
I m using the code below to get value of node from a XML
In the below code I'm trying to loop through each child node and append
I'm using a loop as below to render a label and editor for each
The below program calculates 2 raised to the power n without using any loop,runtime
I'm trying to use sqlite in a 'data services' class like below. I keep
I am using the datatables jquery plugin. I am trying to use it as
I was trying to use IBrokers package with the simplest code like below: library(IBrokers)

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.