Skip to content

Handling Null reference Exception

MaxPayne

Asked Aug 6, 2012, 4:41 AM EDT1 answer
Share
LinkedInX
Hello

I am having problem with this exception "NullReferenceException was unhandled"
i am using this the following method "foreach (DataRow row in ((DataTable)ulDisplay.DataSource).GetChanges().Rows)" to get changes from grid

my goal is
if( flag == 1)
 {
//no change
}
else
{
 make changes only when there is chages on grid
foreach (DataRow row in ((DataTable)ulDisplay.DataSource).GetChanges().Rows)"
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Akkiraju Ivaturi
    0
    Hey, put a break point near foreach statement and examine the ulDisplay first if it is null, then combine ulDisplay.Datasource and check.. Otherwise put everything in try catch and check the stack trace...
    0