Hi Avnindra,
Do you mean that you want to traverse all the values in the datagrid? Which datagrid are you using? DataGrid or DataGridView?
If so, this is the code snippet:
//Traverse DataGrid the data source of which is a DataTable
DataTable dt = dataGrid1.DataSource as DataTable;
for (int row = 0; row < dt.Rows.Count; row++)
for (int col = 0; col < dt.Columns.Count; col++)
{
//Get the value of the cell
object val = dataGrid1[row, col];
}
//Traverse DataGridView
for (int row = 0; row < dataGridView1.Rows.Count; row++)
for (int col = 0; col < dataGridView1.Columns.Count; col++)
{
//Get the value of the cell
object val = dataGridView1[col, row].Value;
}
Please feel free to tell me if I misunderstand you.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.