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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
harry nurmanPosted Jan 19, 2009, 9:55 AM
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
guru koolPosted Jan 14, 2009, 7:04 AM
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";
}