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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:46:12+00:00 2026-05-27T07:46:12+00:00

I have a DataGridView populated from a database, and I need to take each

  • 0

I have a DataGridView populated from a database, and I need to take each row and create an object out of it. I can’t figure out how to do it.

DataGridView Columns: Name Price ProductId Condition MemberId Description

Code I have:

foreach(DataGridViewRow row in members_dg.rows)
{
    foreach(DataGridViewCell cell in row.Cells)
    {
        // need to get info. This should show u what im looking for. 
        //string name = cell1.Text;
        //string price = cell2.Text;
        //etc
        //Member member = new Member(name, price, ...);
    }
}
  • 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-05-27T07:46:13+00:00Added an answer on May 27, 2026 at 7:46 am

    Maybe this?

    foreach(DataGridViewRow row in members_dg.rows)
    {
      // need to get info. This should show u what im looking for. 
      string name = row.Cells[0].Value.ToString();  // first column
      string price = row.Cells[1].Value.ToString();  // second column
      //etc
      Member member = new Member(name, price, ...);
    }
    

    You don’t have to iterate through every cell, just call the cell index for the row you are on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView that is populated from a DataSet. How can I change
I have a datagridview where the users can select which subset of columns to
I have a DataGridView that is populated with 4 columns and multiple rows of
I have a DataGridView on my Form which is being populated with database records
I have a DataGridView bound to a DataTable. The DataTable is populated from a
I have a datagridview populated with data from an .xml file. The data is
I have a DataGridView populated with a BindingList . This list gets saved into
I have a datagridview and a combobox which get populated randomly with data. However,
I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to
I have a datagridview being populated by a collection of objects. the values within

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.