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 9013605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:18:36+00:00 2026-06-16T03:18:36+00:00

I’m iterating through the GridView rows and cells to get the values and store

  • 0

I’m iterating through the GridView rows and cells to get the values and store them in a 2D array.
This is my code:

 for (int i = 0; i < GridView2.Rows.Count; i++)
 {
     for (int j = 0; j < (GridView2.Rows[i].Cells.Count - 3); j++)
     {
         // using the labels of the template fields.....
         Label values = (Label)GridView2.Rows[i].Cells[j].FindControl("Label" + j);
         GridValues[i,j] = values.Text; // gridvalues is my 2d array.    
     }
 }

What I need now is to make the same values I got from the above loop to be added to a list(2D). So I created a class of that list

This is the code:

public  class GridValuesClass
{
    public string GridCustomerName { get; set; }
    public string GridPickUpPoint { get; set; }
    public DateTime GridPickUpDate { get; set; }
    public TimeSpan GridDropPoint { get; set; }
    public DateTime GridDropDate { get; set; }
    public string GridCabStatus { get; set; }
    public string GridAssignedCab { get; set; }
    public TimeSpan GridActualDropTime { get; set; }
}

These properties represent the column names in the gridview.

So, how can I add the values in the gridview inside this class?

And how can I retrieve the values if my values are present in the list<GridValuesClass>

  • 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-16T03:18:38+00:00Added an answer on June 16, 2026 at 3:18 am

    You don’t need to store it in a 2D array to be later stored in a list. Instead you can store it directly in to the list.

    Sort of like this:

    var list = new List<GridValuesClass>();
    
    for (int i = 0; i < GridView2.Rows.Count; i++)
    {
         var job = new GridValuesClass {
              GridPickUpPoint = GridView2.Rows[i].Cells[0]...,
              GridPickUpDate = ...,
              // and so on with possible use of conversions to get the correct types
         }
         list.Add(job);
    }
    

    Hope this helps.


    As a side note, use more meaningful names.

    • Give the class a more meaningful class name than GridValuesClass, if you have several grid views then this name becomes useless. From what I gather on how you named the properties, it looks more like a job order for cabs. So maybe JobOrder?
    • GridView2 tells us nothing. What kind of data does the gridview contain? Perhaps JobsGridView?
    • Is it necessary to prefix all the fields with Grid? What if the data is stored or used in a context where there is no grid view?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
I have an array which has BIG numbers and small numbers in it. I

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.