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, ...);
}
}
Maybe this?
You don’t have to iterate through every cell, just call the cell index for the row you are on.