﻿<?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 - InitializeRow</title><link>http://www.intersoftsolutions.com/Community/Tags/InitializeRow/</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>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/Tags/InitializeRow/</link><pubDate>Tue, 28 Aug 2012 06:28:28 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;See this thread for code example:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.intersoftpt.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/"&gt;http://www.intersoftpt.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There's a sorting problem. When sorting by this Name field, it will get sorted by the value in the DataTable from InitializeDataSource, field List_Name. But in InitializeRow I set the ListName.Text (e.Row.Cells.GetNamedItem("xx").Text) to the value that will be displayed. In the case of this example I prepend just "-DIR-" for folders and "-FIL-" for leaf-nodes. When sorting, it won't get sorted by the displayed text, but by the underlying data field (before updating). For this example, the root-level entry "-FIL-a-" comes before "-DIR-b-", just because "a" comes before "b", but the final text is ignored ("-D.." would come before "-F..").&lt;/p&gt;
&lt;p&gt;How can I make sure the list gets sorted by the displayed text? Would I have to implement CustomSort event? How?&lt;/p&gt;</description></item><item><title>WebGrid: How to access Session object in InitializeRow event handler?</title><link>http://www.intersoftsolutions.com/Community/Tags/InitializeRow/</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>