Hi,
I need to loop through a specific column(Not all the columns) in DataGridview amd update some values: For Example I have dataGridView populated with a csv file and contains 4 column as
Name, Age, Asset
Martin,32,350
John,19,12
Joay,47,1200
humberto,50,950
Richardo,62,23
I present the cells value in DataGridView on a WinForm now I would like to loop through the Columns just by the Column Name. For example How i I can loop through Column = Age and find all ages under 30 and How I can loop throuh the Asset column and add 100 to all values lesss than 500.
Please be advise that I need to serch the column by COULMN NAME because I am not getting the Csv file in the same order as mentioned abouve so i have to use a loop which find the coulmns by thir name
Thanks a lot

SenthilkumarRank #387 · 6.5K reputationPosted Apr 16, 2012, 10:40 PM EDT
foreach(DataGridViewRow dgvr in dgvColumns.Rows)
//Assign the value to the column.
dr["Age"] = 100;
SenthilkumarRank #387 · 6.5K reputationPosted Apr 16, 2012, 10:15 PM EDT
//Assign the value to the column.
Behrouz Hosseini64 reputationPosted Apr 16, 2012, 10:22 PM EDT
Thanks for your reply but can you please let me know how and which part of this code refers to any column name in datagridview? As I already mentioned I need to loop into a specific column (let say Age) and not into whole cells in datagridview
Once again Thanks for your comment
Krishna GaradRank #191 · 12.8K reputationPosted Apr 16, 2012, 10:41 PM EDT
foreach (DataColumn cl in samples.Columns)
{
if (cl.ColumnName.ToString() != "Age")
{
var _values = from DataRow row in samples.Rows
select (string)row[cl.ColumnName.ToString()];
string[] _val = _values.ToArray();
}
}