Hi experts,
Is there a way to loop a datagrid in .Net Compact Framework?. I am implementing an editable column in datagrid, and want to save all in a single button click, just like asp.net gridview.
Brgrds,
Harry
Loop through datagrid
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

guru kool14 reputationPosted Jan 14, 2009, 2:04 AM EST
If dgview is the reference for the gridview then
for(int nCntr=0;nCntr
{
dgGiew.Rows[nCntr].Cells["Column Name"].Value="Value you want to add that particular cell";
}
harry nurman10 reputationPosted Jan 19, 2009, 4:55 AM EST
After googling for couple of days, I finally get result, I will share the code down here. Hope it helps the one who is looking for similar functionalities:
DataTable dt;
dt = (DataTable)dataGrid1.DataSource;
int maxIx = 0;
maxIx = dt.Rows.Count;
try
{
for (int i = 0; i < maxIx; i++)
{
decimal col1= 0;
decimal col2 = 0;
decimal col3 = 0;
dataGrid1.Select(i);
CurrencyManager cm = (CurrencyManager)BindingContext[dataGrid1.DataSource];
cm.Position = i;
//DataRowView drv = (DataRow)cm.Position = i;
DataRowView drv = (DataRowView)cm.Current;
col1 = decimal.Parse(drv.Row["col1"].ToString());
col2 = decimal.Parse(drv.Row["col2"].ToString());
col3 = decimal.Parse(drv.Row["col3"].ToString());
}
}
Regards,
Harry