iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I'm having a problem that for some reason our code is no longer working. I don't know since when exactly. The problem is this: Simple WebGrid. Tree-like structure. Option AllowAutoDataCaching intentionally turned off. Now when the user opens a node and does a resorting in the grid, the tree structure collapses, although there's code to preserve the opened nodes.
Debugging this, I saw that in the InitializeRow event handler I have no access to the Session object.
Please find attached a demo project which shows this behavior.
I know that the used version of WebGrid is outdated, but I assume with newer versions nothing changes in this behaviour.
I cannot switch on AllowAutoDataCaching or change other design decisions. As a solution or workaround maybe I have to switch on something so that the Session is active? I already tried to switch on the four FlyPostBackSettings attributes (see code), although this didn't help. And the data must be stored in the Session object, because this should be preserved even when the user comes back to this page after visiting other pages. Maybe the Session object can be passed in a different way?
If grdMain.IsFlyPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing
instead of
If Not grdMain.IsFlyPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing
I think this problem occurs because "Not grdMain.IsFlyPostBack" always have false value when you do FlyPostBack (it's only true when first initialize. So this prevent you to Expand Self Reference row. It's true if WebGrid do FlyPostBack on Sorting and Expand Child row. I'm using WebGrid 8 and I'm unable to reproduce this issue on our local end. I don't know what causes this matter and I'll investigate this further. But it seems we haven't got any issue about session object. Hope this helps.
Regards,
Bernard
If IsPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing
and the problem doesn't happen in our local end. Hope this helps.
Hi Bernard,
Thanks for your reply and your solution. I'm not sure what caused this and why the Session object was empty while debugging, but changing this fixed the issue and now I can see content in the Session object.
Can you explain this a little more, to get some deeper understanding? I think I do understand the code, but this IsFlyPostBack property is not 100% clear to me. Why would that be there? I'm sure that got copied there for some reason, maybe from an example or so. And at least at some point this code worked.
From what I understand, the FlyPostBack is the dynamic postback done by JavaScript from your control and handled on the server-side just lika AJAX, by returning partially rendered content. When would this be called here (for sorting?) and why would we want to test for this property within the InitializeRow event handler?
And why would we need to even test for IsPostBack (in your new code)? Because even for initial load, we would like to expand the nodes as well (from the last visit of that page).
The problem is solved, but I'd like to get more understanding of what happened here and to avoid such mistakes in the future.
Thanks
Update: Today I had this problem again (Session empty in InitializeRow event handler). But it happened only with this sample, not in our real program. I did not make any other changes. Even restarting Visual Studio, closing all browsers, etc. did not help. After rebooting my PC (and deleting browser cache) everything seems to work again. It's probably not related to the cache, because I also tried to set all no-caching options in Page.Init event without success before rebooting. Is there any known bug related to this in V6? Anyway, this just confirms I was not dreaming yesterday that I saw the Session object empty and the questions above are still open.
I suggest you forget the "Session empty" issue for now if there's no known bug. As mentioned, it gets fixed after reboot, so it might be something local or whatever. As long as the problem is solved in our main project by applying the discussed code change, we don't need to hunt these ghosts.
For the code, I removed the entire first part of the IF statement and just test if the Session object is there and in this case just apply the data (expand the node) - no checking of any kind of PostBack. I think that's the best way. I don't see any reason to test for PostBacks at all, because even for initial page load this should be done if the user returns to this page after visiting other pages.
The only open question is to understand all this. Why should we ever test for the IsFlyPostBack property here? This was probably copied from some sample code.
Eric
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname