DataRow cell value?  
Author Message
CSharpShooter





PostPosted: Visual C# General, DataRow cell value? Top

Hi all,

[C# 2.0]
I'm looping through a DataRow & would like to know if the cell is empty

DataTable dt = dataGridView1.DataSource as DataTable;
foreach (DataRow row in dt.Rows)
{
// if the cell in column "value" is empty check the next row in value...
}

I can do it with the below code but not with the above... I'd like to keep the DataRow statements as they are & just check for an empty cell in a column.

foreach (DataGridViewRow rows in dataGridView1.Rows)
{
if (rows.Cells["value"].Value.ToString() == "") { ... ; }
}

Thanks all.



Visual C#8  
 
 
boban.s





PostPosted: Visual C# General, DataRow cell value? Top

Did you tried this:
DataTable dt = dataGridView1.DataSource as DataTable;
foreach (DataRow row in dt.Rows)
{
if (row ["value"].ToString().Length == 0)
{ ... ; }
}


 
 
CSharper85





PostPosted: Visual C# General, DataRow cell value? Top

Thanks ;-)