On a page, we have a RadGrid. We're running into some problems that I am thinking might have to do with events firing, and in what order they fire. The error comes if you sort a column, then click to sort it again. After tracing down the code-behind, I think I see the problem, but I am curious if this is intended behavior, or if there's something we can do. The problem on our end stems from a particular variable in the code-behind. The variable is actually an object reference, and the error is a null reference exception thrown inside the Grid's ItemCreated event. The object is set in a private method called in the Page_Load event.
I would post the code, but it is well over 1,000 lines long. So for simplicity's sake, here's the order of events I traced:
1) I enter the page -> Page_Load fires, populates the object reference and binds the RadGrid, also firing ItemCreated and using the reference with no problems
2) I click a column -> Page_Load fires again, populates the object reference again and apparently re-binds the RadGrid, firing the ItemCreated event and using the reference with no problems.
3) I click the same column to sort in the opposite direction -> ItemCreated fires and the object reference is null, crashing.
The private method call in Page_Load is NOT dependent on the page being a postback or not, - it is always called on Page_Load. So why does Page_Load fire on the first sort, but not on the second sort?
Thanks in advance for any help offered!
Ando Poore
I would post the code, but it is well over 1,000 lines long. So for simplicity's sake, here's the order of events I traced:
1) I enter the page -> Page_Load fires, populates the object reference and binds the RadGrid, also firing ItemCreated and using the reference with no problems
2) I click a column -> Page_Load fires again, populates the object reference again and apparently re-binds the RadGrid, firing the ItemCreated event and using the reference with no problems.
3) I click the same column to sort in the opposite direction -> ItemCreated fires and the object reference is null, crashing.
The private method call in Page_Load is NOT dependent on the page being a postback or not, - it is always called on Page_Load. So why does Page_Load fire on the first sort, but not on the second sort?
Thanks in advance for any help offered!
Ando Poore