﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Thu, 30 Aug 2012 00:15:23 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>Hi Eric,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Perhaps, IsFlyPostBack prevent the code to be called in first initialize and this property indicate FlyPostBack event on WebGrid. Hope this helps.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Regards,&lt;/div&gt;
&lt;div&gt;Bernard&lt;/div&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Wed, 29 Aug 2012 04:03:01 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>&lt;p&gt;Hi Bernard,&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Eric&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Tue, 28 Aug 2012 22:23:32 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>Hi Eric,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;It's my mistake. I've tried to put grdMain.IsFlyPostBack and your project works fine. You can try to put:&lt;/div&gt;
&lt;div&gt;&lt;pre&gt;If grdMain.IsFlyPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing&lt;/pre&gt;&lt;p&gt;instead of&lt;/p&gt;&lt;p /&gt;&lt;pre&gt;If Not grdMain.IsFlyPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing&lt;/pre&gt;&lt;p&gt;I think this problem occurs because "&lt;span style="font-size: 10pt; "&gt;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. &lt;/span&gt;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.&lt;span style="font-size: 10pt; "&gt; Hope this helps.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt; "&gt;Regards,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt; "&gt;Bernard&lt;/span&gt;&lt;/p&gt;&lt;p /&gt;&lt;/div&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Tue, 28 Aug 2012 04:10:19 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>&lt;p&gt;Hi Bernard,&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt;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).&lt;/p&gt;
&lt;p&gt;The problem is solved, but I'd like to get more understanding of what happened here and to avoid such mistakes in the future.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Tue, 28 Aug 2012 03:12:12 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>Hi Eric,&lt;div&gt;&lt;br /&gt;&lt;div&gt;I can replicate your issue here. Unfortunately, I can read session object in Initialize Row event. Probably the problem occurs because this validation:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;If Not grdMain.IsFlyPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;I tried to debug in here and found out that&amp;nbsp;&lt;span style="font-size: 10pt; "&gt;grdMain.IsFlyPostBack has false value. To resolve this, I change the code to:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre&gt;If IsPostBack AndAlso Session(cSessionState_Expanded_WebGridRows) IsNot Nothing&lt;/pre&gt;
&lt;p&gt;and the problem doesn't happen in our local end. Hope this helps.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bernard&lt;/p&gt;
&lt;div&gt;&lt;span style="font-size: 10pt; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/</link><pubDate>Mon, 27 Aug 2012 12:13:27 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>Session</category><category>sort</category><category>InitializeRow</category><category>AllowAutoDataCaching</category><category>tree</category><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Debugging this, I saw that in the InitializeRow event handler I have no access to the Session object.&lt;/p&gt;
&lt;p&gt;Please find attached a demo project which shows this behavior.&lt;/p&gt;
&lt;p&gt;I know that the used version of WebGrid is outdated, but I assume with newer versions nothing changes in this behaviour.&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>