how to read data from one column of datagridview
Try this
string data = string.Empty;
int indexOfYourColumn = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
data = row.Cells[indexOfYourColumn].Value;
try this
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.ColumnIndex == 0) //Set your Column Index
{
//DO your Stuff here..
}
}
}
or the other way
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
if (col.Name == "MyColName")
{
//DO your Stuff here..
}
}
Maybe this helps too. To get one cell:
string data = (string)DataGridView1[iCol, iRow].Value;
Then you can simply loop rows and columns.
Documentation.