I am getting an error:object reference not set to an instance of an object
ma code:
for (int i = 0; i < dgPreveleges.RowCount - 1; i++)
{
if((string)dgPreveleges.Rows[i].Cells["dgColSelectAll"].Value.ToString () == "false")
{
MessageBox.Show("hi");
}
}
plz help me to rectify this error
Loading
Sukesh MarlaPosted Sep 1, 2012, 6:30 AM
If your problem still persisit share your code.
VulpesPosted Sep 1, 2012, 6:28 AM
To adjust for that, try:
for (int i = 0; i < dgPreveleges.RowCount - 1; i++)
{
object val = dgPreveleges.Rows[i].Cells["dgColSelectAll"].Value;
if (val != null && val.ToString() == "false")
{
MessageBox.Show("hi");
}
else
{
MessageBox.Show("empty cell or value not false");
}
}