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
Datagridview
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Sep 1, 2012, 2:28 AM EDT
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");
}
}
Sukesh MarlaRank #461 · 5.4K reputationPosted Sep 1, 2012, 2:30 AM EDT
If your problem still persisit share your code.