<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5386271279942260625</atom:id><lastBuildDate>Wed, 26 Feb 2025 20:52:44 +0000</lastBuildDate><category>Asp.Net</category><category>.Net</category><category>NetTiers</category><category>Generics</category><category>Telerik</category><category>Sql Server</category><category>jQuery</category><category>Ajax</category><category>Codesmith</category><category>Kendo</category><category>KnockoutJs</category><category>ORM</category><title>Martin Olivares MS Web Stack experiences</title><description>&lt;a href=&quot;http://www.blogger.com/profile/02591931560125455338&quot;&gt;Freelance Asp.Net Architect/Developer&lt;/a&gt;</description><link>http://martinolivarespick.blogspot.com/</link><managingEditor>noreply@blogger.com (Martín Olivares)</managingEditor><generator>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-1373470536471334843</guid><pubDate>Sun, 21 Jun 2015 00:03:00 +0000</pubDate><atom:updated>2015-06-20T21:03:38.137-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Kendo</category><title>Kendo Grid State Manager Plugin</title><description>I&#39;ve developed a Kendo plugin to manage kendo grid states (filtering/sorting/grouping) that allows create, re-use and share grid &quot;views&quot;.&lt;br /&gt;
&lt;br /&gt;
This is my first GitHub project and could be found at:&amp;nbsp;&lt;a href=&quot;https://github.com/martinolivares/kendo-gridstatemanager-plugin&quot; target=&quot;_blank&quot;&gt;https://github.com/martinolivares/kendo-gridstatemanager-plugin&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Below a preview:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/martinolivares/kendo-gridstatemanager-plugin/master/images/kendoGridStateManager.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;451&quot; src=&quot;https://raw.githubusercontent.com/martinolivares/kendo-gridstatemanager-plugin/master/images/kendoGridStateManager.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Hope you find it useful ;)</description><link>http://martinolivarespick.blogspot.com/2015/06/kendo-grid-state-manager-plugin.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-7171792996709477233</guid><pubDate>Fri, 22 Jun 2012 22:17:00 +0000</pubDate><atom:updated>2012-06-22T19:17:36.353-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><category domain="http://www.blogger.com/atom/ns#">KnockoutJs</category><title>Realtime data editing using an Excel-like grid and KnockoutJs</title><description>&lt;div&gt;
Sometimes you need to edit a batch data requiring an agile UI that allow:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Send changes without need confirmation&lt;/li&gt;
&lt;li&gt;Quickly Navigate to any field that you want edit&lt;/li&gt;
&lt;li&gt;Provide a visual indicator of the updated fields&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;
An example: Realtime Weather Forecast Editor
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
On this example, the main requirement is allow quickly edit the cities temperatures at different day times. Basically for each city could edit the morning, afternoon or midnight temperature. For simplicity, the cities list are stored in a session variable.
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
This is a list of the implementation techniques for the app main features:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Updates are sent back to the server when textboxes lost focus&lt;/u&gt;: using a &lt;a href=&quot;http://knockoutjs.com/documentation/extenders.html&quot; target=&quot;_blank&quot;&gt;KnockoutJs extender&lt;/a&gt; the temperature fields changes are captured and sent to server using ajax calls.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;
Updated values are highlighted&lt;/u&gt;: a &lt;a href=&quot;http://knockoutjs.com/documentation/css-binding.html&quot; target=&quot;_blank&quot;&gt;css binding&lt;/a&gt; changes the textbox background color after a field is updated successfully on server 
&lt;/li&gt;
&lt;li&gt;&lt;u&gt;
Key based navigation&lt;/u&gt;: a jQuery handler allow navigate between textboxes using the arrows keys&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
App Screenshot&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNYkUrjXN3bfKjWEXa3UVa_qtyhHoWNn6lNRwuzOqAA2WlOa1ue4XktMpnBu7iaRFJ348C5txlPcI28gRMpGRW8khxh_dye67uA4nCB5_9W8_l517XA6r96fpv2UKcV-g22ykEvn4B1Es/s1600/Realtime+Grid+Editor.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNYkUrjXN3bfKjWEXa3UVa_qtyhHoWNn6lNRwuzOqAA2WlOa1ue4XktMpnBu7iaRFJ348C5txlPcI28gRMpGRW8khxh_dye67uA4nCB5_9W8_l517XA6r96fpv2UKcV-g22ykEvn4B1Es/s1600/Realtime+Grid+Editor.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;strong&gt;
Using a KnockoutJs extender to send the realtime updates
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
A new extender named &quot;realtime&quot; is added to the Knockout extenders. At the initialization, it stores in two private fields (cityId and dayTime) the values required to identify the time slot to be updated on the ajax call after the observable property value changes.
Also, a sub-observable (hasChanged) is used to notify the highlighter databinder.
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;ko.extenders.realtime = &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(target, options) {
    &lt;span class=&quot;rem&quot;&gt;// store private vars to use as parameters on updates&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;// cityId: the key of entity to be updated&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;// daytime: the field of entity to be updated (Morning/Afternoon/Midnight)&lt;/span&gt;
    target.cityId = options[0];
    target.daytime = options[1];
    
    &lt;span class=&quot;rem&quot;&gt;//add a sub-observable to mantain a changed flag&lt;/span&gt;
    target.hasChanged = ko.observable(&lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;);

    &lt;span class=&quot;rem&quot;&gt;//define a function to send updates&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; update(newValue) {
             $.ajax({
                 url: &lt;span class=&quot;str&quot;&gt;&quot;/home/updateforecast&quot;&lt;/span&gt;, 
                data: { cityId: target.cityId, daytime: target.daytime, value: newValue },
                type: &lt;span class=&quot;str&quot;&gt;&quot;post&quot;&lt;/span&gt;, 
                success: &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(result) 
                {
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(result) 
                        target.hasChanged(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
                }
            });
    }

    &lt;span class=&quot;rem&quot;&gt;//update whenever the value changes&lt;/span&gt;
    target.subscribe(update);

    &lt;span class=&quot;rem&quot;&gt;//return the original value&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; target;
};
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;strong&gt;
Applying the extender
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
The extender is applied on the ForecastModel temperature fields
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; model = @Html.Raw(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer().Serialize(Model));
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; viewModel = { 
    forecasts :  ko.observableArray(ko.utils.arrayMap(model, &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(forecast) {
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ForecastModel(forecast);
    }))
   
}; 
   
&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; ForecastModel(forecast) {
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.City = ko.observable(forecast.City);
    &lt;span class=&quot;rem&quot;&gt;// extend the observable fields that will be updated in realtime&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Morning = ko.observable(forecast.Morning).extend({realtime:[forecast.Id, &lt;span class=&quot;str&quot;&gt;&quot;Morning&quot;&lt;/span&gt;]});
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Afternoon = ko.observable(forecast.Afternoon).extend({realtime:[forecast.Id, &lt;span class=&quot;str&quot;&gt;&quot;Afternoon&quot;&lt;/span&gt;]});
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Midnight = ko.observable(forecast.Midnight).extend({realtime:[forecast.Id, &lt;span class=&quot;str&quot;&gt;&quot;Midnight&quot;&lt;/span&gt;]});
}

ko.applyBindings(viewModel);
&lt;/pre&gt;
&lt;div&gt;
&lt;strong&gt;
Configuring the View
&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
A table (tblForecasts) is used to display the cities names and edit the different day times temperatures. On each temperature textbox the &quot;value binding&quot; is applied to each temperature field. Also, a &quot;css binding&quot; to the hasChanged sub-observable is applied in order to highlight the textbox background color when a change callback returns successfully from server.
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    Realtime Weather Forecast Editor&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;tblForecasts&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                City
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                Morning
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                Afternoon
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                Midnight
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;template: { name: &#39;forecastRowTemplate&#39;, foreach: forecasts }&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/html&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;forecastRowTemplate&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; 
&amp;lt;tr&amp;gt; 
    &amp;lt;td&amp;gt;&amp;lt;span data-bind=&lt;span class=&quot;str&quot;&gt;&quot;text: City&quot;&lt;/span&gt;/&amp;gt;&amp;lt;/td&amp;gt; 
    &amp;lt;td&amp;gt;&amp;lt;input data-bind=&lt;span class=&quot;str&quot;&gt;&quot;value: Morning, css: { hasChanged: Morning.hasChanged }&quot;&lt;/span&gt;/&amp;gt;&amp;lt;/td&amp;gt; 
    &amp;lt;td&amp;gt;&amp;lt;input data-bind=&lt;span class=&quot;str&quot;&gt;&quot;value: Afternoon, css: { hasChanged: Afternoon.hasChanged }&quot;&lt;/span&gt;/&amp;gt;&amp;lt;/td&amp;gt; 
    &amp;lt;td&amp;gt;&amp;lt;input data-bind=&lt;span class=&quot;str&quot;&gt;&quot;value: Midnight, css: { hasChanged: Midnight.hasChanged }&quot;&lt;/span&gt;/&amp;gt;&amp;lt;/td&amp;gt; 
&amp;lt;/tr&amp;gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;strong&gt;
Adding keyboard navigation to table
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
A simple handler is attached to the textboxes keydown event to detect the arrows keys pressing and move focus
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;$(&lt;span class=&quot;str&quot;&gt;&quot;#tblForecasts&quot;&lt;/span&gt;).on(&lt;span class=&quot;str&quot;&gt;&quot;keydown&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;input:text&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(e) {
        &lt;span class=&quot;rem&quot;&gt;// detect arrows pressing&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (e.keyCode &amp;lt; 37 || e.keyCode &amp;gt; 40)
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;

        e.preventDefault();
  
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; target;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; cellAndRow = $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).parents(&lt;span class=&quot;str&quot;&gt;&#39;td,tr&#39;&lt;/span&gt;);
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; cellIndex = cellAndRow[0].cellIndex;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; rowIndex = cellAndRow[1].rowIndex;

        &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (e.keyCode) {
            &lt;span class=&quot;rem&quot;&gt;// left arrow                 &lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; 37:
                cellIndex = cellIndex - 1;                        
                &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
            &lt;span class=&quot;rem&quot;&gt;// right arrow                 &lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; 39:
               cellIndex = cellIndex + 1;                        
                &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
            &lt;span class=&quot;rem&quot;&gt;// up arrow                 &lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; 40:
                rowIndex = rowIndex + 1;
                &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
            &lt;span class=&quot;rem&quot;&gt;// down arrow                 &lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; 38:
                rowIndex = rowIndex - 1;
                &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
        }
        target = $(&lt;span class=&quot;str&quot;&gt;&#39;table tr&#39;&lt;/span&gt;).eq(rowIndex).find(&lt;span class=&quot;str&quot;&gt;&#39;td&#39;&lt;/span&gt;).eq(cellIndex).find(&lt;span class=&quot;str&quot;&gt;&quot;input:text&quot;&lt;/span&gt;);
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (target != undefined) {
            target.focus();
            target.select();
        }
});
&lt;/pre&gt;
&lt;div&gt;
&lt;strong&gt;
Server side code
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;The Forecast Model
&lt;/u&gt;&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Forecast
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Id { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; City { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Morning { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Afternoon { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Midnight { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
}
&lt;/pre&gt;
&lt;div&gt;
&lt;u&gt;The Controller
&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
Just contains the code to initialize the cities list on session and a method to update the temperatures
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; C_ForecastModels = &lt;span class=&quot;str&quot;&gt;&quot;ForecastModels&quot;&lt;/span&gt;;

&lt;span class=&quot;rem&quot;&gt;// Expose the stored Forecasts from Session&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; IEnumerable&amp;lt;Forecast&amp;gt; ForecastModels
{
    &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (Session[C_ForecastModels] == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
        {
            Session[C_ForecastModels] = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt;[] {
                &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Forecast { Id=1, City=&lt;span class=&quot;str&quot;&gt;&quot;Barcelona&quot;&lt;/span&gt;, Morning=90, Afternoon=45, Midnight=40},                &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Forecast { Id=2, City=&lt;span class=&quot;str&quot;&gt;&quot;Berlin&quot;&lt;/span&gt;, Morning=78, Afternoon=34, Midnight=0 },
                &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Forecast { Id=3, City=&lt;span class=&quot;str&quot;&gt;&quot;New York&quot;&lt;/span&gt;, Morning=45, Afternoon=35, Midnight=20 },
                &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Forecast { Id=4, City=&lt;span class=&quot;str&quot;&gt;&quot;Sydney&quot;&lt;/span&gt;, Morning=65, Afternoon=45, Midnight=40 },
                &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Forecast { Id=5, City=&lt;span class=&quot;str&quot;&gt;&quot;Tokio&quot;&lt;/span&gt;, Morning=74, Afternoon=70, Midnight=60 }
            };
        }
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Session[C_ForecastModels] &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; IEnumerable&amp;lt;Forecast&amp;gt;;
    }
    &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt; { Session[C_ForecastModels] = value; }
}

 &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; ActionResult Index()
 {
     &lt;span class=&quot;rem&quot;&gt;// Return the Session stored Forecasts&lt;/span&gt;
     &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; View(ForecastModels);
 }

 &lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;
 &lt;span class=&quot;rem&quot;&gt;// Update Forecast value for selected daytime (Morning/Afternoon/Midnight)&lt;/span&gt;
 [HttpPost]
 &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; JsonResult Updateforecast(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; cityId, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; daytime, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; value)
 {
     &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; cityForecast = ForecastModels.SingleOrDefault(forecastModel =&amp;gt; forecastModel.Id == cityId);
     &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (cityForecast == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
         &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Json(&lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;);
     &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (daytime)
     {
         &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;Morning&quot;&lt;/span&gt;:
             cityForecast.Morning = value;
             &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
         &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;Afternoon&quot;&lt;/span&gt;:
             cityForecast.Afternoon = value;
             &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
         &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;Midnight&quot;&lt;/span&gt;:
             cityForecast.Midnight = value;
             &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
     }
     &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Json(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
 }
&lt;/pre&gt;
&lt;div&gt;
&lt;strong&gt;
Conclusion
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
This is a basic example to demonstrate the &lt;a href=&quot;http://knockoutjs.com/&quot; target=&quot;_blank&quot;&gt;KnockoutJs&lt;/a&gt; extenders usage. The realtime edition on the grid and the keyboard navigation resembles the old DOS applications, but still is a powerful technique for some specific scenarios (I&#39;ve worked in some projects on that this type of UI was explicitly required by the client or app end users).&lt;br /&gt;
Enjoy!&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;
Project files
&lt;/strong&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;120&quot; scrolling=&quot;no&quot; src=&quot;https://skydrive.live.com/embed?cid=7956156ED33B1D49&amp;amp;resid=7956156ED33B1D49%21302&amp;amp;authkey=AHtYt80_ODCHZwk&quot; width=&quot;98&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;</description><link>http://martinolivarespick.blogspot.com/2012/06/realtime-data-editing-using-excel-like.html</link><author>noreply@blogger.com (Martín Olivares)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNYkUrjXN3bfKjWEXa3UVa_qtyhHoWNn6lNRwuzOqAA2WlOa1ue4XktMpnBu7iaRFJ348C5txlPcI28gRMpGRW8khxh_dye67uA4nCB5_9W8_l517XA6r96fpv2UKcV-g22ykEvn4B1Es/s72-c/Realtime+Grid+Editor.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-6155238334697345633</guid><pubDate>Tue, 15 Sep 2009 14:19:00 +0000</pubDate><atom:updated>2009-09-18T17:45:52.779-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><category domain="http://www.blogger.com/atom/ns#">NetTiers</category><category domain="http://www.blogger.com/atom/ns#">Telerik</category><title>Telerik + Nettiers series</title><description>&lt;span style=&quot;font-weight:bold;&quot;&gt;Radgrid paging, sorting, grouping and sorting with Nettiers objectdatasource&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This post starts a new serie of post to demostrate the combination of two cools asp.net tools: Telerik Suite &amp;amp; Nettiers&lt;br /&gt;This example shows the use of the more common features of Radgrid as paging, sorting, filtering and grouping with a Nettiers object datasource.&lt;br /&gt;Some helpfull notes:&lt;br /&gt;1) The objectdatasource method used to retrieve the data is &lt;b&gt;GetPaged&lt;/b&gt;.&lt;br /&gt;2) The code in &lt;b&gt;OnSelecting&lt;/b&gt; event of the object datasource set correct the parameters for the objectdatasource.&lt;br /&gt;3) The &lt;b&gt;EnableLinqExpressions&lt;/b&gt; of radgrid is set to false to avoid by pass the objectdatasource results.&lt;br /&gt;4) The &lt;b&gt;CanRetrieveAllData&lt;/b&gt; of mastertableview is set to false in order to get a correct sorting.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIEFjWbnka1GOSLpFT2K63ia7qZvRtTTu2Fkppf2DxIvjTvMBgoHI4EU0CEUPguz3DtHfRibZ0PKdYeoYcoermUGQw7JiNjoP5ddYbw5I3gd46zwjnjLMND9ETHjkMkTOxR41-c76B2Uw/s1600-h/radgrid.png&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 400px; height: 197px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIEFjWbnka1GOSLpFT2K63ia7qZvRtTTu2Fkppf2DxIvjTvMBgoHI4EU0CEUPguz3DtHfRibZ0PKdYeoYcoermUGQw7JiNjoP5ddYbw5I3gd46zwjnjLMND9ETHjkMkTOxR41-c76B2Uw/s400/radgrid.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5381699438349383474&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;The aspx page&lt;/span&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Radgrid.aspx.cs&quot; Inherits=&quot;Radgrid&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Register Assembly=&quot;Telerik.Web.UI&quot; Namespace=&quot;Telerik.Web.UI&quot; TagPrefix=&quot;telerik&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;PUBLIC&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadScriptManager&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RadScriptManager1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadScriptManager&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadGrid&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RadGrid1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowGroupPanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;GridLines&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;None&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataSourceID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmployeeDataSource1&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;AllowFilteringByColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowAutomaticDeletes&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowAutomaticUpdates&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;AllowAutomaticInserts&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnPreRender&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RadGrid1_PreRender&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowPaging&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;AllowSorting&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Skin&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;WebBlue&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;PageSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;10&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;EnableLinqExpressions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;AllowCustomPaging&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;MasterTableView&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;GroupLoadMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;client&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowMultiColumnSorting&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CommandItemDisplay&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;TopAndBottom&quot;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;attr&quot;&gt;DataSourceID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmployeeDataSource1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataKeyNames&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmployeeId&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CanRetrieveAllData&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;attr&quot;&gt;AllowCustomSorting&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;PagerStyle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AlwaysVisible&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;MasterTableView&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ClientSettings&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowDragToGroup&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowColumnsReorder&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ReorderColumnsOnClient&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Selecting&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowRowSelect&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ClientSettings&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadGrid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;data:EmployeeDataSource&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmployeeDataSource1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;EnablePaging&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;EnableSorting&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;SelectMethod&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;GetPaged&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;EnableCaching&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnSelecting&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmployeeDataSource1_OnSelecting&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;data:EmployeeDataSource&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;The code behind&lt;/span&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Radgrid : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; masterTableFilter = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; EmployeeDataSource1_OnSelecting(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, ObjectDataSourceSelectingEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Set the pagesize in each selecting to avoid the Int32.MaxValue (2147483647) passed by some Radgrid versions when filtering&lt;/span&gt;&lt;br /&gt;        e.Arguments.MaximumRows = RadGrid1.PageSize;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Clear the master table filterExpression &lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.IsNullOrEmpty(RadGrid1.MasterTableView.FilterExpression))&lt;br /&gt;        {&lt;br /&gt;            masterTableFilter = RadGrid1.MasterTableView.FilterExpression;&lt;br /&gt;            RadGrid1.MasterTableView.FilterExpression = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Set the Nettiers Datasource parameters &lt;/span&gt;&lt;br /&gt;        e.InputParameters[&lt;span class=&quot;str&quot;&gt;&quot;WhereClause&quot;&lt;/span&gt;] = masterTableFilter;&lt;br /&gt;        e.InputParameters[&lt;span class=&quot;str&quot;&gt;&quot;OrderBy&quot;&lt;/span&gt;] = RadGrid1.MasterTableView.SortExpressions.GetSortString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;rem&quot;&gt;// Restore the master table filterExpression &lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; RadGrid1_PreRender(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        RadGrid1.MasterTableView.FilterExpression = masterTableFilter;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2009/09/telerik-nettiers-series.html</link><author>noreply@blogger.com (Martín Olivares)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIEFjWbnka1GOSLpFT2K63ia7qZvRtTTu2Fkppf2DxIvjTvMBgoHI4EU0CEUPguz3DtHfRibZ0PKdYeoYcoermUGQw7JiNjoP5ddYbw5I3gd46zwjnjLMND9ETHjkMkTOxR41-c76B2Uw/s72-c/radgrid.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-7358623126051240939</guid><pubDate>Thu, 23 Jul 2009 14:32:00 +0000</pubDate><atom:updated>2009-07-23T17:49:58.991-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net</category><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><category domain="http://www.blogger.com/atom/ns#">NetTiers</category><category domain="http://www.blogger.com/atom/ns#">ORM</category><category domain="http://www.blogger.com/atom/ns#">Sql Server</category><title>Efficient Nettiers Deepload - Filling object graphs in just one database call</title><description>After using several ORM&#39;s I found that when need a &lt;a href=&quot;http://en.wikipedia.org/wiki/Object_graph&quot;&gt;complete object graph&lt;/a&gt; or some related entities (INNER/LEFT JOIN &quot;like&quot;) they haven&#39;t an efficient approach built-in.&lt;br /&gt;Almost all ORM can lazy load related properties (collections or instances) that means additional db calls and specifically in Nettiers filling an object with n-childs implies (n+1) database calls with the related performance penalty.&lt;br /&gt;On this post, I want expose one alternative to populate an entire object graph in just one database call.&lt;br /&gt;The concept it&#39;s very simple and consists on &lt;a href=&quot;http://en.wikipedia.org/wiki/Serialization&quot;&gt;deserialize&lt;/a&gt; a string returned from the database that contains an xml with the representation of the entire object graph.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&quot;In one application that uses the AdventureWorks database you need to get the orders with their order details and the product referenced in the order detail for a selected customer.&quot;&lt;/i&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;1) First develop a simple method to take a look to the string that the deserializer is expecting.&lt;/span&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;u&gt;&lt;b&gt;Usage:&lt;/b&gt;&lt;/u&gt;&lt;/pre&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; sampleData = GetSampleData(676);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;u&gt;&lt;b&gt;Method:&lt;/b&gt;&lt;/u&gt;&lt;/pre&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; GetSampleData(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; customerId)&lt;br /&gt;{&lt;br /&gt;SalesOrderHeaderService salesOrderHeaderService = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SalesOrderHeaderService();&lt;br /&gt;Type[] childTypes = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Type[] { &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(TList&amp;lt;SalesOrderDetail&amp;gt;), &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(Product) };&lt;br /&gt;TList&amp;lt;SalesOrderHeader&amp;gt; salesOrders = salesOrderHeaderService.DeepLoadByCustomerID(customerId&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:16px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:13px;&quot;&gt;, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;, DeepLoadType.IncludeChildren, childTypes);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; EntityHelper.SerializeXml&amp;lt;SalesOrderHeader&amp;gt;(salesOrders);&lt;br /&gt;}&lt;/pre&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;2) Create an stored procedure that returns an xml with the representation of the entire object graph&lt;/span&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;PROCEDURE&lt;/span&gt; [dbo].[SalesOrdersGetWithDetailsAndProductsByCustomerId]&lt;br /&gt;@customerId &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;,&lt;br /&gt;@&lt;span class=&quot;kwrd&quot;&gt;result&lt;/span&gt; ntext &lt;span class=&quot;kwrd&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SET&lt;/span&gt; NOCOUNT &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SET&lt;/span&gt; @&lt;span class=&quot;kwrd&quot;&gt;result&lt;/span&gt;=&lt;br /&gt;&lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&amp;gt;&amp;lt;ArrayOfSalesOrderHeader xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&amp;gt;&#39;&lt;/span&gt;&lt;br /&gt;+&lt;br /&gt;(&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; SalesOrderHeader.*,&lt;br /&gt;   &lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;SalesOrderDetailCollection&amp;gt;&#39;&lt;/span&gt; +&lt;br /&gt;   (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; SalesOrderDetail.*,&lt;br /&gt;       (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; Product.*&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Production.Product Product&lt;br /&gt;               &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; Product.ProductID = SalesOrderDetail.ProductID&lt;br /&gt;                   &lt;span class=&quot;kwrd&quot;&gt;FOR&lt;/span&gt; XML RAW (&lt;span class=&quot;str&quot;&gt;&#39;ProductIDSource&#39;&lt;/span&gt;), ELEMENTS)&lt;br /&gt;       &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail SalesOrderDetail&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; SalesOrderDetail.SalesOrderID = SalesOrderHeader.SalesOrderID&lt;br /&gt;               &lt;span class=&quot;kwrd&quot;&gt;FOR&lt;/span&gt; XML AUTO, ELEMENTS)&lt;br /&gt;   +  &lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;/SalesOrderDetailCollection&amp;gt;&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;&lt;br /&gt;   Sales.SalesOrderHeader SalesOrderHeader&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; SalesOrderHeader.CustomerID = @customerId&lt;br /&gt;   &lt;span class=&quot;kwrd&quot;&gt;FOR&lt;/span&gt; XML AUTO, ELEMENTS)&lt;br /&gt;+&lt;br /&gt;&lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;/ArrayOfSalesOrderHeader&amp;gt;&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; @&lt;span class=&quot;kwrd&quot;&gt;result&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;END&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;3) Call the SP and deserialize the result&lt;/span&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;u&gt;&lt;b&gt;Usage:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;TList&amp;lt;SalesOrderHeader&amp;gt; customerSalesOrders = SalesOrdersGetWithDetailsAndProductsByCustomerId(676);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;u&gt;&lt;b&gt;Method:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; TList&amp;lt;SalesOrderHeader&amp;gt; SalesOrdersGetWithDetailsAndProductsByCustomerId(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; customerId)&lt;br /&gt;{&lt;br /&gt;SqlCommand command = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlCommand(&lt;span class=&quot;str&quot;&gt;&quot;SalesOrdersGetWithDetailsAndProductsByCustomerId&quot;&lt;/span&gt;);&lt;br /&gt;command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;SqlParameter param = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@result&quot;&lt;/span&gt;, SqlDbType.VarChar);&lt;br /&gt;param.Direction = ParameterDirection.Output;&lt;br /&gt;param.Size = 10000;&lt;br /&gt;command.Parameters.Add(param);&lt;br /&gt;command.Parameters.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@customerId&quot;&lt;/span&gt;, customerId));&lt;br /&gt;DataRepository.Provider.ExecuteNonQuery(command);&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; resultParameter = command.Parameters[0].Value.ToString().Replace(&lt;span class=&quot;str&quot;&gt;&quot;&amp;amp;lt;&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;&quot;&lt;/span&gt;).Replace(&lt;span class=&quot;str&quot;&gt;&quot;&amp;amp;gt;&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;&amp;gt;&quot;&lt;/span&gt;).Replace(&lt;span class=&quot;str&quot;&gt;&quot;&amp;amp;amp;lt;&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;&quot;&lt;/span&gt;).Replace(&lt;span class=&quot;str&quot;&gt;&quot;&amp;amp;amp;gt;&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;&amp;gt;&quot;&lt;/span&gt;);&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; EntityHelper.DeserializeListXml&amp;lt;SalesOrderHeader&amp;gt;(resultParameter);&lt;br /&gt;}&lt;/pre&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;br /&gt;- Remove XmlIgnore Attribute for the related entities that you want populate. You can identify them by the &quot;Source&quot; sufix (ProductIDSource in the example).&lt;br /&gt;- Attributes serialization is case sensitive, if you has applied some style on the UsePascalCasing codesmith template property, your class fields names casing could be different that the db field definition. In this case use field aliasing in the stored procedure select clause.&lt;br /&gt;- To deepload a collection put the subquery on the select fields and enclose with the collections delimiter (&#39;SalesOrderDetailCollection&#39; in the example).&lt;/div&gt;&lt;div&gt;&lt;salesorderdetailcollection&gt;- To deepload a one to one relation put the subquery on the select fields and use for &quot;RAW&quot; in FOR XML clause to overwrite the row element name generated automatically (&#39;ProductIDSource&#39; in the example).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/salesorderdetailcollection&gt;&lt;/div&gt;</description><link>http://martinolivarespick.blogspot.com/2009/07/efficient-nettiers-deepload-filling.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-5283395594162223327</guid><pubDate>Wed, 29 Oct 2008 14:20:00 +0000</pubDate><atom:updated>2008-10-29T12:33:12.900-02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Codesmith</category><title>Codesmith Method Picker Property</title><description>I just published my first project on Codeplex. The project is a Codesmith add-in, below is the project Url, description and a screenshot. Hope that the Codesmith users find this helpful.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Project Description&lt;/strong&gt;&lt;br /&gt;This project is a custom property for Codesmith that allows select methods from assemblies. &lt;br /&gt;You can choose a set of methods and use this list to any purpose as generate a webservice to expose them, make method tests or a javascript method call wrapper.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Project Url&lt;/strong&gt;&lt;br /&gt;&lt;a href=&quot;http://www.codeplex.com/MethodPickerProp&quot;&gt;Codesmith Method Picker Property&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUI0bwfLzPbmdwLMGYZStNRedih2OnY7jojHmCZUEs325LeM3UTZUXA5l7QHq1JJZdHkJ46KUexGYi0YNaTxO9XG-aFPV8qwLIj2SY8jwC7R9xVtZ5WFO8v6LFY_9zaopZQ8JkvYiSxsc/s1600-h/MethodPicker.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 400px; height: 224px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUI0bwfLzPbmdwLMGYZStNRedih2OnY7jojHmCZUEs325LeM3UTZUXA5l7QHq1JJZdHkJ46KUexGYi0YNaTxO9XG-aFPV8qwLIj2SY8jwC7R9xVtZ5WFO8v6LFY_9zaopZQ8JkvYiSxsc/s400/MethodPicker.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5262582440860882002&quot; /&gt;&lt;/a&gt;</description><link>http://martinolivarespick.blogspot.com/2008/10/codesmith-method-picker-property.html</link><author>noreply@blogger.com (Martín Olivares)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUI0bwfLzPbmdwLMGYZStNRedih2OnY7jojHmCZUEs325LeM3UTZUXA5l7QHq1JJZdHkJ46KUexGYi0YNaTxO9XG-aFPV8qwLIj2SY8jwC7R9xVtZ5WFO8v6LFY_9zaopZQ8JkvYiSxsc/s72-c/MethodPicker.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-2060235965906100045</guid><pubDate>Sun, 29 Jun 2008 14:04:00 +0000</pubDate><atom:updated>2008-06-29T12:05:48.858-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>jQuery Carousel Example</title><description>&lt;div&gt;A cool way to show a items gallery is using a scrollable div as Amazon displays related books for the current selected book. This technique is known as &quot;carousel&quot;. I made an example (&lt;a title=&quot;Download source&quot; href=&quot;http://www.exodus.com.ar/blogs/martinolivares/jQuery%20Carousel%20in%20asp.net.rar&quot;&gt;Download source (85Kb)&lt;/a&gt;) that shows a list of motherboards using a &lt;a href=&quot;http://sorgalla.com/projects/jcarousel/&quot;&gt;jQuery Carousel Component&lt;/a&gt; populated dinamically via Ajax queries (useful when haves a large items quantity to show)&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL3yBfMeJwOkS4741gwfVRFm-GV9szOqqoI2b7hH0gOBk05KqdzIMWDB9ssQchSpXozKn7YW1_Vs4qxtPYa9crTA4Qt8jTO_vsKH0T9kg-RLZz49lD024XU71uIEUWu50WdeiVaw8vtPc/s1600-h/jQuery+carousel.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5217304924164334530&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL3yBfMeJwOkS4741gwfVRFm-GV9szOqqoI2b7hH0gOBk05KqdzIMWDB9ssQchSpXozKn7YW1_Vs4qxtPYa9crTA4Qt8jTO_vsKH0T9kg-RLZz49lD024XU71uIEUWu50WdeiVaw8vtPc/s400/jQuery+carousel.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Server side pagination method&lt;/strong&gt;&lt;br /&gt;The request/response to the method that returns a &quot;page&quot; of the carousel are maded using JSON.&lt;br /&gt;For simplicity the pagination is done against a generic collection, but easily can be a database query.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;    [WebMethod]&lt;br /&gt;&lt;br /&gt;    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; List&amp;lt;Motherboard&amp;gt; GetItems(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; pageIndex, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; pageSize)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        List&amp;lt;Motherboard&amp;gt; motherboards = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;Motherboard&amp;gt;&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Asus P5Q Deluxe&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Asus P5Q Deluxe Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, P45 Express, ATX, 16GB DDR2, 1600MHz FSB&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;GigaByte GA-P35-DS3L&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;GigaByte GA-P35-DS3L Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, P35 Express, ATX, 8GB DDR, 1333MHz FSB &quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Intel D5400XS&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel D5400XS Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket J LGA771, P35 Express, Extended ATX, 8GB DDR2, 1600MHz FSB &quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Asus M3N-HT Deluxe Mempipe&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Asus M3N-HT Deluxe Mempipe Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Socket AM2+, nVIDIA nForce 780a, ATX, 8GB DDR2, 2600MHz FSB&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;ABIT IP35 PRO XE&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;ABIT IP35 PRO XE Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, P35 Express, ATX, 8GB DDR2, 1600MHz FSB&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Asus Striker Extreme&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Asus Striker Extreme Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Quad-Core/Core 2 Duo Extreme/Core 2 Duo/Pentium D/Celeron D, Socket T&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;XFX MB-N780-ISH9&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;XFX MB-N780-ISH9 Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, nForce 780i SLI, ATX, 8GB DDR2, 1333MHz FSB &quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;HP Asus P5BW-LA&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;HP Asus P5BW-LA Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, P965 Express, Micro ATX, 8GB DDR2, 1066MHz FSB&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Biostar P4M900-M4&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Biostar P4M900-M4 Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Core 2 Quad/Pentium D/Pentium 4/Celeron D, Socket T SLI, ATX, 8GB DDR2, 1333MHz Bus&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;MSI P6N Diamond&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;MSI P6N Diamond Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, nForce 680i SLI, ATX, 8GB DDR2, 1333MHz FS&quot;&lt;/span&gt;),        &lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;Intel D915GAG&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel D915GAG Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Pentium 4/Celeron D, Socket T, 915G, mATX, 4GB DDR, 800MHz FSB&quot;&lt;/span&gt;),&lt;br /&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Motherboard(&lt;span class=&quot;str&quot;&gt;&quot;ABIT IP35-E&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;ABIT IP35-E Motherboard&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;Intel Socket T LGA775, P35 Express, ATX, 8GB DDR2, 1333MHz FSB &quot;&lt;/span&gt;),        &lt;br /&gt;&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; motherboards.GetRange((pageIndex - 1) * pageSize, pageSize);&lt;br /&gt;&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Client side pagination method&lt;/strong&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; mycarousel_makeRequest(carousel, first, last, per_page, page)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;rem&quot;&gt;// Lock carousel until request has been made&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    carousel.&lt;span class=&quot;kwrd&quot;&gt;lock&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;rem&quot;&gt;// Call the server side method with pageIndex and pageSize parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    $.ajax({&lt;br /&gt;&lt;br /&gt;    type: &lt;span class=&quot;str&quot;&gt;&quot;POST&quot;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;    url: &lt;span class=&quot;str&quot;&gt;&quot;Default.aspx/GetItems&quot;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;    data: &lt;span class=&quot;str&quot;&gt;&quot;{&#39;pageIndex&#39;:&#39;&quot;&lt;/span&gt; + page + &lt;span class=&quot;str&quot;&gt;&quot;&#39;, &#39;pageSize&#39;:&#39;&quot;&lt;/span&gt; + per_page + &lt;span class=&quot;str&quot;&gt;&quot;&#39;}&quot;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;    contentType: &lt;span class=&quot;str&quot;&gt;&quot;application/json; charset=utf-8&quot;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;    dataType: &lt;span class=&quot;str&quot;&gt;&quot;json&quot;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;    success: &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(data) {&lt;br /&gt;&lt;br /&gt;            mycarousel_itemAddCallback(carousel, first, last, data.d, page);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        });&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; mycarousel_itemAddCallback(carousel, first, last, data, page)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;rem&quot;&gt;// Unlock &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    carousel.unlock();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class=&quot;rem&quot;&gt;// Set size&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     carousel.size(12);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; per_page = carousel.last - carousel.first + 1;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;     &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = first; i &amp;lt;= last; i++)&lt;br /&gt;&lt;br /&gt;     {&lt;br /&gt;&lt;br /&gt;         &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; pos = i - 1;&lt;br /&gt;&lt;br /&gt;         &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; idx = Math.round(((pos / per_page) - Math.floor(pos / per_page)) * per_page);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         carousel.add(i, mycarousel_getItemHTML(data[idx]));&lt;br /&gt;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt; * Buil item html &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; mycarousel_getItemHTML(mother)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; item = &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;div&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;img src=&#39;images/&quot;&lt;/span&gt; + mother.Image + &lt;span class=&quot;str&quot;&gt;&quot;.jpg&#39; alt=&#39;&quot;&lt;/span&gt; + mother.Title + &lt;span class=&quot;str&quot;&gt;&quot;&#39;&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;div class=&#39;Title&#39;&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += mother.Title;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;div class=&#39;Description&#39;&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    item += mother.Description;&lt;br /&gt;&lt;br /&gt;    item += &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; item;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a title=&quot;Download source&quot; href=&quot;http://www.exodus.com.ar/blogs/martinolivares/jQuery%20Carousel%20in%20asp.net.rar&quot;&gt;&lt;br /&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5217313241765337090&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrlKirPGZRySgTxd-8ipkG921jPUBb8htJxiswAqTIXwWSjL5Gnih_GbtxVqQ2IxjThfJec76wy823A_xLdL9AJM2nnhmTUsJYQZIvZu4vZRz_ZOXIvBKvhYqlnYH8VvCWS5RtKsgW4fY/s200/down1.jpg&quot; height=&quot;30&quot; border=&quot;0&quot; /&gt;Download source: jQuery Carousel in asp.net.rar (85Kb)&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://martinolivarespick.blogspot.com/2008/06/jquery-carousel-sample.html</link><author>noreply@blogger.com (Martín Olivares)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL3yBfMeJwOkS4741gwfVRFm-GV9szOqqoI2b7hH0gOBk05KqdzIMWDB9ssQchSpXozKn7YW1_Vs4qxtPYa9crTA4Qt8jTO_vsKH0T9kg-RLZz49lD024XU71uIEUWu50WdeiVaw8vtPc/s72-c/jQuery+carousel.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-2145902696183753145</guid><pubDate>Tue, 06 May 2008 00:45:00 +0000</pubDate><atom:updated>2008-06-05T19:59:13.420-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net</category><category domain="http://www.blogger.com/atom/ns#">Generics</category><title>Generics Examples - Generating instances with two methods or how to simplify the DAL</title><description>&lt;p&gt;&lt;span&gt;In this delivery two methods to generate instances or collections of our entities, simplifying therefore the code of our &lt;a href= &quot; http://en.wikipedia.org/wiki/Data_access_layer &quot; &gt;DAL&lt;/a&gt; (traditionally composed by a great amount of methods and mappings “field to field” from tables to objects). Once collected the data using a DataReader, with these methods is possible to obtain a single entity instance or a strong typed collection of instances. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Methods&lt;/b&gt; &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt;// A single instance&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; FillEntity&amp;lt;T&amp;gt;(T instance, IDataRecord datarecord)&lt;br /&gt;{&lt;br /&gt;    Type instanceType = instance.GetType();&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; datarecord.FieldCount; i++)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (datarecord[i] != DBNull.Value)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; propName = datarecord.GetName(i);&lt;br /&gt;            PropertyInfo propInfo = instanceType.GetProperty(propName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propInfo != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                propInfo.SetValue(instance, datarecord[propInfo.Name], &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt;// A instance collection&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; List&amp;lt;T&amp;gt; FillEntities&amp;lt;T&amp;gt;(IDataReader dr)&lt;br /&gt;{&lt;br /&gt;    List&amp;lt;T&amp;gt; entities = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;T&amp;gt;();&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; (dr.Read())&lt;br /&gt;    {&lt;br /&gt;        T instance = Activator.CreateInstance&amp;lt;T&amp;gt;();&lt;br /&gt;        Utils.FillEntity&amp;lt;T&amp;gt;(instance, dr);&lt;br /&gt;        entities.Add(instance);&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; entities;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Using the methods&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt;// A Single Instance&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; UserInfo UserGetById(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; userid)&lt;br /&gt;{&lt;br /&gt;    UserInfo userInfo = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; UserInfo();&lt;br /&gt;    Database db = DatabaseFactory.CreateDatabase();&lt;br /&gt;    DbCommand dbCommand = db.GetStoredProcCommand(&lt;span class=&quot;str&quot;&gt;&quot;usergetbyid&quot;&lt;/span&gt;);&lt;br /&gt;    db.AddInParameter(dbCommand, &lt;span class=&quot;str&quot;&gt;&quot;userid&quot;&lt;/span&gt;, DbType.String, userid);&lt;br /&gt;    IDataReader idr = db.ExecuteReader(dbCommand);&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (idr.Read())&lt;br /&gt;    {&lt;br /&gt;        Utils.FillEntity&amp;lt;UserInfo&amp;gt;(userInfo, idr);&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; userInfo;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;rem&quot;&gt;// A instance collection&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; List&amp;lt;OrderInfo&amp;gt; GetOrders(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; customerid)&lt;br /&gt;{&lt;br /&gt;    Database db = DatabaseFactory.CreateDatabase();&lt;br /&gt;    DbCommand dbCommand = db.GetStoredProcCommand(&lt;span class=&quot;str&quot;&gt;&quot;getorders&quot;&lt;/span&gt;);    &lt;br /&gt;    db.AddInParameter(dbCommand, &lt;span class=&quot;str&quot;&gt;&quot;customerid&quot;&lt;/span&gt;, DbType.Int32, customerid);&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Utils.FillEntities&amp;lt;OrderInfo&amp;gt;(db.ExecuteReader(dbCommand));&lt;br /&gt;}&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2007/06/ejemplos-generics-generando-instancias.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-1136244724279536207</guid><pubDate>Sat, 26 Apr 2008 00:39:00 +0000</pubDate><atom:updated>2008-06-05T20:02:16.793-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net</category><category domain="http://www.blogger.com/atom/ns#">Generics</category><title>Generics Examples - Passing paramaters to Stored Procedures</title><description>&lt;p&gt;&lt;span&gt;In this post begins a series of examples of application of Generics that were useful to me throughout several developments. In this delivery a generic method that receives an instance of some entity of our domain and a DbCommand, and based on the SqlParameterAttributes attributes “reflected” from the entity maps the value of the properties with the parameters of stored procedure of the received DbCommand. Using this only method and “decorating” with the SqlParameterAttribute attributes the suitable properties of our classes it is possible to simplify the stored procedures calls. &lt;br /&gt; &lt;br /&gt;&lt;strong&gt;The Method&lt;/strong&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; MatchStoreProceduresParams&amp;lt;T&amp;gt;(T entity, DbCommand command)&lt;br /&gt;{&lt;br /&gt;    Type type = entity.GetType();&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (PropertyInfo entityProperty &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; type.GetProperties())&lt;br /&gt;    {&lt;br /&gt;        SqlParameterAttribute[] propSqlAttributeArray = (SqlParameterAttribute[])entityProperty.GetCustomAttributes(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(SqlParameterAttribute), &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;);&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propSqlAttributeArray.Length &amp;gt; 0)&lt;br /&gt;        {&lt;br /&gt;            SqlParameterAttribute propSqlAttribute = propSqlAttributeArray[0];&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propSqlAttribute != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                SqlParameter sqlParam = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlParameter();&lt;br /&gt;                sqlParam.ParameterName = propSqlAttribute.Name;&lt;br /&gt;                sqlParam.SqlDbType = propSqlAttribute.SqlDbType;&lt;br /&gt;                sqlParam.Value = entityProperty.GetValue(entity, &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;);&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propSqlAttribute.IsDirectionDefined)&lt;br /&gt;                {&lt;br /&gt;                    sqlParam.Direction = propSqlAttribute.Direction;    &lt;br /&gt;                }&lt;br /&gt;                command.Parameters.Add(sqlParam);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Using the method&lt;/strong&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; CustomerSave(CustomerInfo customer)&lt;br /&gt;{&lt;br /&gt;    Database db = DatabaseFactory.CreateDatabase();&lt;br /&gt;    DbCommand dbCommand = db.GetStoredProcCommand(&lt;span class=&quot;str&quot;&gt;&quot;CustomerUpdate&quot;&lt;/span&gt;);&lt;br /&gt;    Utils.MatchStoreProceduresParams(customer, dbCommand);&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; db.ExecuteNonQuery(dbCommand);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Decorando la clase&lt;/strong&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; CustomerInfo&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; _id;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _name;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; _age;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;decimal&lt;/span&gt; _balance;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; CustomerInfo()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    [SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@CustomerId&quot;&lt;/span&gt;, System.Data.SqlDbType.Int)]&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Id&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _id; }&lt;br /&gt;        set { _id = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    [SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@FirstName&quot;&lt;/span&gt;, System.Data.SqlDbType.Char)]&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _name; }&lt;br /&gt;        set { _name = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@Age&quot;&lt;/span&gt;, System.Data.SqlDbType.Int)]&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Age&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _age; }&lt;br /&gt;        set { _age = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [SqlParameter(&lt;span class=&quot;str&quot;&gt;&quot;@Balance&quot;&lt;/span&gt;, System.Data.SqlDbType.Decimal)]&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;decimal&lt;/span&gt; Balance&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _balance; }&lt;br /&gt;        set { _balance = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/p&gt;</description><link>http://martinolivarespick.blogspot.com/2007/06/ejemplos-generics-pasando-parmetros.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-1945028943261482252</guid><pubDate>Mon, 21 Apr 2008 00:20:00 +0000</pubDate><atom:updated>2008-04-20T21:48:31.944-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><category domain="http://www.blogger.com/atom/ns#">Telerik</category><title>Telerik Radgrid: showing hierarchical data using a Dataset with multiple tables example</title><description>The telerik radgrid is one of the most complete grid control in the market. Have a cool set of features and covers the most commonly scenaries. &lt;br /&gt;A common UI requirement is show Hierarchycal data, this data can be loaded in several ways with or without postbacks changing the property &quot;HierarchyLoadMode&quot;. In case that the set of data to show is not great (use your criteria), you can choose load all data in the client obtaining a more responsive UI. To minimize roundtrips to database a good choice is code an stored procedure that returns multiple results and obtain a DataSet with multiple tables.&lt;br /&gt;I make an example based on the AdventureWorks db to show the Departments and their respective employees.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Stored Procedure:&lt;/strong&gt;&lt;br /&gt;This SP gets the data from Departments and Employees returning two results that share one column (DepartmentId) to make the parent/child relation. &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;PROCEDURE&lt;/span&gt; [HumanResources].[Department_Get_DepartmentAndEmployees]&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/* &lt;span class=&quot;kwrd&quot;&gt;Get&lt;/span&gt; the departments */&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; HRD.DepartmentID, HRD.Name &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; DepartmentName&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; HumanResournces.Department HRD&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; DepartmentName&lt;br /&gt;&lt;br /&gt;/* &lt;span class=&quot;kwrd&quot;&gt;Get&lt;/span&gt; the employees */&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; PC.FirstName, &lt;br /&gt;       PC.LastName,&lt;br /&gt;       HRE.Title,&lt;br /&gt;       HRDep.DepartmentId&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;&lt;br /&gt;HumanResources.Employee HRE&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; Person.Contact PC &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; PC.ContactId = HRE.ContactId&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; HumanResources.EmployeeDepartmentHistory HRDep &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; HRDep.EmployeeId = HRE.EmployeeId&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The .aspx Code:&lt;/strong&gt;&lt;br /&gt;Note the ParentTableRelation tag uses the DepartmentId field to make the relation from the Employees table to the Department table.&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Register Assembly=&quot;Telerik.Web.UI&quot; Namespace=&quot;Telerik.Web.UI&quot; TagPrefix=&quot;telerik&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;PUBLIC&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Telerik Radgrid: showing hierarchical data using a Dataset with multiple tables&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ScriptManager&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Scriptmanager1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ScriptManager&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadGrid&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;gvEmployeesByDepartment&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;95%&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AutoGenerateColumns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;attr&quot;&gt;GridLines&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;None&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowHeader&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Skin&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Web20&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;MasterTableView&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataMember&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Departments&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataKeyNames&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentId&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;100%&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Customers&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HierarchyLoadMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Client&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DetailTables&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridTableView&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataMember&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Employees&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataKeyNames&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentId&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;100%&quot;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowHeader&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ParentTableRelation&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridRelationFields&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DetailKeyField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentId&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;MasterKeyField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentId&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ParentTableRelation&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowIndicatorColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CurrentFilterFunction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;NoFilter&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FilterListOptions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;VaryByDataType&quot;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;attr&quot;&gt;Visible&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowIndicatorColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ExpandCollapseColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CurrentFilterFunction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;NoFilter&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FilterListOptions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;VaryByDataType&quot;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;attr&quot;&gt;Visible&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Resizable&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ExpandCollapseColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Columns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Title&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;UniqueName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Title&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ReadOnly&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HeaderText&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Title&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;FirstName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;UniqueName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;FirstName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ReadOnly&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;br /&gt;                            &lt;span class=&quot;attr&quot;&gt;HeaderText&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;First Name&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LastName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;UniqueName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LastName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ReadOnly&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;br /&gt;                            &lt;span class=&quot;attr&quot;&gt;HeaderText&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Last Name&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Columns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridTableView&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DetailTables&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowIndicatorColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CurrentFilterFunction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;NoFilter&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FilterListOptions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;VaryByDataType&quot;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;attr&quot;&gt;Visible&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowIndicatorColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ExpandCollapseColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CurrentFilterFunction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;NoFilter&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FilterListOptions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;VaryByDataType&quot;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;attr&quot;&gt;Resizable&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;False&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;HeaderStyle&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ExpandCollapseColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Columns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataField&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;UniqueName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;DepartmentName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HeaderText&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Department&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:GridBoundColumn&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Columns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;MasterTableView&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;telerik:RadGrid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The .cs Code:&lt;/strong&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; _Default :System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(!Page.IsPostBack)&lt;br /&gt;            BindDepartmentsAndEmployees();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; BindDepartmentsAndEmployees()&lt;br /&gt;    {&lt;br /&gt;        SqlConnection conn = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlConnection(&lt;span class=&quot;str&quot;&gt;@&quot;Integrated Security=SSPI;Persist Security Info=False;User ID=marketpoint;Initial Catalog=AdventureWorks;Data Source=(local)\sqlexpress&quot;&lt;/span&gt;);&lt;br /&gt;        SqlCommand cmd = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlCommand(&lt;span class=&quot;str&quot;&gt;&quot;[HumanResources].[Department_Get_DepartmentAndEmployees]&quot;&lt;/span&gt;, conn);&lt;br /&gt;        cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;        SqlDataAdapter da = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlDataAdapter(cmd);&lt;br /&gt;        DataSet dsDepartmentAndEmployees = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataSet();&lt;br /&gt;        da.Fill(dsDepartmentAndEmployees);&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(da != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Renames Dataset table to get more clear names in grid declarative properties&lt;/span&gt;&lt;br /&gt;            dsDepartmentAndEmployees.Tables[0].TableName = &lt;span class=&quot;str&quot;&gt;&quot;Departments&quot;&lt;/span&gt;;&lt;br /&gt;            dsDepartmentAndEmployees.Tables[1].TableName = &lt;span class=&quot;str&quot;&gt;&quot;Employees&quot;&lt;/span&gt;;&lt;br /&gt;            gvEmployeesByDepartment.DataSource = dsDepartmentAndEmployees;&lt;br /&gt;            gvEmployeesByDepartment.DataBind();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;The UI Result (Click to Enlarge):&lt;/strong&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqw_-ooovEdQO4y5Kaa0k2uDZYwljo3IkJ_xb9wnWl3LYi48lgA4xE48gqiDvPGD2b80NZVENmrTYB1wwJMXkgQq1HbBDUw3Wh9ju4PgcnkrDJRQ-y2etRgIDSCLPtby2gJmv-_Cxsamg/s1600-h/DepartmentsAndEmployees.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqw_-ooovEdQO4y5Kaa0k2uDZYwljo3IkJ_xb9wnWl3LYi48lgA4xE48gqiDvPGD2b80NZVENmrTYB1wwJMXkgQq1HbBDUw3Wh9ju4PgcnkrDJRQ-y2etRgIDSCLPtby2gJmv-_Cxsamg/s400/DepartmentsAndEmployees.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5191490886608839346&quot; /&gt;&lt;/a&gt;</description><link>http://martinolivarespick.blogspot.com/2008/04/telerik-radgrid-show-hierarchical-data.html</link><author>noreply@blogger.com (Martín Olivares)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqw_-ooovEdQO4y5Kaa0k2uDZYwljo3IkJ_xb9wnWl3LYi48lgA4xE48gqiDvPGD2b80NZVENmrTYB1wwJMXkgQq1HbBDUw3Wh9ju4PgcnkrDJRQ-y2etRgIDSCLPtby2gJmv-_Cxsamg/s72-c/DepartmentsAndEmployees.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-8027510859059611290</guid><pubDate>Fri, 04 Apr 2008 21:08:00 +0000</pubDate><atom:updated>2008-06-05T19:59:53.216-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">NetTiers</category><title>NetTiers: Expose custom stored procedures as componentlayer methods</title><description>Sometimes is needed a custom functionality that goes far that the CRUD functionality generated by NetTiers. To acomplish this task we can use a custom stored procedure to get the data and expose it as a method of the componentlayer (services layer).&lt;br /&gt;Follow the next steps to expose a custom stored procedure:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1) Configure Codesmith properties&lt;/strong&gt;&lt;br /&gt; CustomProceduresStartsWith (example: {1}{0}_)&lt;br /&gt; ProcedurePrefix (example: cust_sp_ )&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2) Add a Stored Procedure &lt;/strong&gt;&lt;br /&gt;Add a SP with a name that follows the convention defined in CustomProceduresStartsWith where {1} is the placeholder for&lt;br /&gt;ProcedurePrefix and {0} is the placeholder for the TableName, for example cust_sp_Contact_GetBySalesOrderCountBetween (using AdventureWorks db)&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;PROCEDURE&lt;/span&gt; [dbo].[cust_sp_Contact_GetBySalesOrderCountBetween]&lt;br /&gt;&lt;br /&gt;    @&lt;span class=&quot;kwrd&quot;&gt;min&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;,&lt;br /&gt;    @&lt;span class=&quot;kwrd&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;BEGIN&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;SET&lt;/span&gt; NOCOUNT &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Person.Contact C&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; &lt;br /&gt;    (&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;COUNT&lt;/span&gt;(*) &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader SOH&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; SOH.ContactId = C.ContactId) &lt;span class=&quot;kwrd&quot;&gt;BETWEEN&lt;/span&gt; @&lt;span class=&quot;kwrd&quot;&gt;min&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; @&lt;span class=&quot;kwrd&quot;&gt;max&lt;/span&gt;&lt;br /&gt;END&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;3) Run the template&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4) Use the method&lt;/strong&gt;&lt;br /&gt;Now in the componentlayer for the entity we have our custom stored procedure exposed as a method &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;ContactService contactService = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ContactService();&lt;br /&gt;gvContacts.DataSource = contactService.GetBySalesOrderCountBetween(25, 30);&lt;br /&gt;gvContacts.DataBind(); &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note: the return type of the custom stored procedure method can be a TList&lt;Entity&gt; or the defined in the CustomNonMatchingReturnType property (DataSet/IDataReader).&lt;br /&gt;To determine what type will be return a method compares every column order and type returned from the Sp with every column order and type of the Entity table.&lt;br /&gt;Debugging a bit the template, I have reviewed the method that compares the stored procedure column type with the table column type. This method returns false if some column type returned has no equivalent (File: \TemplateLib\CommonSqlCode.cs Method: IsMatching)&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!SqlTypesAreEquivalent(command.CommandResults[0].Columns[i].NativeType, table.Columns[i].NativeType))&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt; If you have UDT (User-Defined Data Types) fields in your table this method will be return false and CustomNonMatchingReturnType will be setted as Method Return type. &lt;br /&gt;&lt;br /&gt;Usually is preferible that have an TList&lt;enrity&gt; as method return than a Dataset or a IDataReader, because in this way you have all the NetTiers functionality to manipulate the data (deepload the TList returned for example). To force return a TList when have &lt;br /&gt;UDT fields you can edit the file \TemplateLib\CommonSqlCode.cs and change in the method IsMatching the above line for this:&lt;br /&gt; &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!SqlTypesAreEquivalent(command.CommandResults[0].Columns[i].DataType.ToString(), table.Columns[i].DataType.ToString()))        &lt;br /&gt;&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2007/10/nettiers-expose-custom-stored.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-29240659288348458</guid><pubDate>Thu, 06 Mar 2008 19:12:00 +0000</pubDate><atom:updated>2008-03-06T17:51:19.851-02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>Export Html to Pdf using iTextSharp</title><description>This is an example to export from html to pdf using &lt;a href=&quot;http://itextsharp.sourceforge.net/&quot;&gt;iTextSharp&lt;/a&gt;. In this case I used a html template file with some token fields that are replaced and after exported to pdf.&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GeneratePDF()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Set output folder to /pdf&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; outputFolder = HttpContext.Current.Server.MapPath(&lt;span class=&quot;str&quot;&gt;&quot;pdf&quot;&lt;/span&gt;);&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Set output file name to a Guid based name&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; pdfFileName = outputFolder + &lt;span class=&quot;str&quot;&gt;&quot;\\&quot; + Guid.NewGuid().ToString() + &quot;&lt;/span&gt;.pdf&lt;span class=&quot;str&quot;&gt;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        Document iTextSharpDocument = new Document(new Rectangle(880, 700));&lt;br /&gt;        FileStream fs = new FileStream(pdfFileName, FileMode.CreateNew);&lt;br /&gt;        PdfWriter writer = PdfWriter.GetInstance(iTextSharpDocument, fs);&lt;br /&gt;        iTextSharpDocument.Open();&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Read the html template and replace values&lt;/span&gt;&lt;br /&gt;        string templatePath = HttpContext.Current.Server.MapPath(&quot;&lt;/span&gt;html/ReportTemplate.html&lt;span class=&quot;str&quot;&gt;&quot;&lt;/span&gt;);&lt;br /&gt;        TextReader templateReader = new StreamReader(templatePath);&lt;br /&gt;        StringBuilder sbTemplate = new StringBuilder(templateReader.ReadToEnd());&lt;br /&gt;        sbTemplate.Replace(&quot;&lt;/span&gt;[@title]&lt;span class=&quot;str&quot;&gt;&quot;, &quot;&lt;/span&gt;Sales&lt;span class=&quot;str&quot;&gt;&quot;);&lt;br /&gt;        sbTemplate.Replace(&quot;&lt;/span&gt;[@name]&lt;span class=&quot;str&quot;&gt;&quot;, &quot;&lt;/span&gt;Jhon Smith&lt;span class=&quot;str&quot;&gt;&quot;);&lt;br /&gt;        sbTemplate.Replace(&quot;&lt;/span&gt;[@date]&quot;, DateTime.Now.ToString());&lt;br /&gt;&lt;br /&gt;        XmlDocument htmlDoc = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; XmlDocument();&lt;br /&gt;        htmlDoc.LoadXml(sbTemplate.ToString());&lt;br /&gt;&lt;br /&gt;        HtmlParser.Parse(iTextSharpDocument, htmlDoc);&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;rem&quot;&gt;// Release resources&lt;/span&gt;&lt;br /&gt;        templateReader.Close();&lt;br /&gt;&lt;br /&gt;        iTextSharpDocument.Close();&lt;br /&gt;        writer.Close();&lt;br /&gt;&lt;br /&gt;        writer = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;        iTextSharpDocument = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        fs.Close();&lt;br /&gt;        fs.Dispose();&lt;br /&gt;    }&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2008/03/export-html-to-pdf-using-itextsharp.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-7519643600086409176</guid><pubDate>Mon, 03 Dec 2007 20:57:00 +0000</pubDate><atom:updated>2008-04-20T21:42:25.920-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">NetTiers</category><category domain="http://www.blogger.com/atom/ns#">Telerik</category><title>NetTiers &quot;SELECT DISTINCT&quot; method</title><description>Using Nettiers CRUD methods and &lt;a href=&quot;http://martinolivarespick.blogspot.com/2007/10/nettiers-expose-custom-stored.html&quot;&gt;custom methods&lt;/a&gt; we get a very complete DAL that covers a wide range of the queries needed by a application. A frequently question in forums is about how obtain a &quot;Select Distinct&quot; clause equivalent in Nettiers. I&#39;ve developed a method to obtain the distinct entities based on the values of one or more properties. &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; TList&amp;lt;T&amp;gt; SelectDistinctFromList&amp;lt;T&amp;gt;(TList&amp;lt;T&amp;gt; originalList, System.Enum[] distinctProperties) &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; T : IEntity, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;        Type instanceType = originalList.GetType().GetGenericArguments()[0].BaseType;&lt;br /&gt;&lt;br /&gt;        PropertyInfo[] propertyColumns = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyInfo[distinctProperties.Length];&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; distinctProperties.Length; i++)&lt;br /&gt;        {&lt;br /&gt;            propertyColumns[i] = instanceType.GetProperty(distinctProperties[i].ToString());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        TList&amp;lt;T&amp;gt; resultList = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; TList&amp;lt;T&amp;gt;();&lt;br /&gt;        System.Collections.Specialized.StringCollection keys = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; System.Collections.Specialized.StringCollection();&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (T instance &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; originalList)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; key = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (PropertyInfo pi &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; propertyColumns)&lt;br /&gt;            {&lt;br /&gt;                key += pi.GetValue(instance, &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;) + &lt;span class=&quot;str&quot;&gt;&quot;|&quot;&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!keys.Contains(key))&lt;br /&gt;            { &lt;br /&gt;                keys.Add(key);&lt;br /&gt;                resultList.Add(instance);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; resultList;&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;As you can see there are two steps to get the &quot;Select Distinct&quot;, in the first step is retrieve the base collection (TList&lt;entity&gt;) and in the second step apply the SelectDistinctFromList method. &lt;br /&gt;This approach is adequate when the first step data is cached, have not a big collection or want to do many &quot;Select Distinct&quot; over the collection. For example, using a Nettiers project generated from &lt;br /&gt;the AdventureWorks DB first obtains the orders for a SalesPerson and after get a list of orders with the distinct Territories and other list with the distinct Customers and Status.&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;SalesOrderHeaderService service = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SalesOrderHeaderService();&lt;br /&gt;TList&amp;lt;SalesOrderHeader&amp;gt; orders = service.GetBySalesPersonId(279);&lt;br /&gt;&lt;br /&gt;TList&amp;lt;SalesOrderHeader&amp;gt; distinctTerritoriesFromOrders = SelectDistinctFromList&amp;lt;SalesOrderHeader&amp;gt;(orders, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Enum[] { SalesOrderHeaderColumn.TerritoryId });&lt;br /&gt;&lt;br /&gt;TList&amp;lt;SalesOrderHeader&amp;gt; distinctCustomerAndStatusFromOrders = SelectDistinctFromList&amp;lt;SalesOrderHeader&amp;gt;(orders, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Enum[] { SalesOrderHeaderColumn.CustomerId, SalesOrderHeaderColumn.Status });&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2007/12/nettiers-select-distinct-method.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-3679957638369366431</guid><pubDate>Tue, 07 Aug 2007 14:10:00 +0000</pubDate><atom:updated>2009-04-20T15:31:37.995-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net</category><category domain="http://www.blogger.com/atom/ns#">Generics</category><title>Reflect the underlying type of nullable property / field</title><description>Sometimes it&#39;s necessary list the properties with their types of an entity instanciated at run-time. For example when develop a CRUD form at runtime for a selected entity or when build a designer form like a report designer or expression designer that implies entities and her properties. This task is not problematic using Reflection, but if we use Nullable properties (and we would have to use it whenever a value can be null) the underlying type of a nullable property can&#39;t be obtained in the traditional way.  A nullable property is a &quot;constructed type&quot; of the Nullable&amp;lt;T&amp;gt; generic class, this means that the type of the property is the parameter for the constructor of Nullable&amp;lt;T&amp;gt; (For example a nullable int property is an instance of Nullable&amp;lt;int&amp;gt;). I wrote a method that list the properties with their types iterating over the reflected properties adding his name and type to a dictionary, and when it finds a generic property obtains the underlying type of the property using the argument that was supplied to construct the nullable type.&lt;br /&gt;Below a sample of using the method to list the properties and types of a run-time instantiated entity.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Reflection;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; _Default : System.Web.UI.Page &lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; SortedDictionary&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt; GetPropertiesAndDataTypes(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; entityName)&lt;br /&gt;    {&lt;br /&gt;        SortedDictionary&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt; dict = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SortedDictionary&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;();&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; propertyType = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(entityName))&lt;br /&gt;        {&lt;br /&gt;            Type type = Type.GetType(entityName);&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (type != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                PropertyInfo[] properties = type.GetProperties();&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (properties != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; properties.Length &amp;gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (PropertyInfo propertyInfo &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; properties)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propertyInfo.PropertyType.IsGenericType)&lt;br /&gt;                        {&lt;br /&gt;                            Type nullableProperty = Type.GetType(propertyInfo.PropertyType.FullName);&lt;br /&gt;                            &lt;span class=&quot;rem&quot;&gt;// Obtains the Name of the type used as parameter of Nullable&amp;lt;T&amp;gt;&lt;/span&gt;&lt;br /&gt;                            propertyType = nullableProperty.GetGenericArguments()[0].FullName; &lt;br /&gt;                        }&lt;br /&gt;                        &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;&lt;br /&gt;                        {&lt;br /&gt;                            propertyType = propertyInfo.PropertyType.FullName;&lt;br /&gt;                        }&lt;br /&gt;                        dict.Add(propertyInfo.Name, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0} ({1})&quot;&lt;/span&gt;, propertyInfo.Name, propertyType));&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; dict;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ddlEntities_SelectedIndexChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        lbEntityProperties.Items.Clear();&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (ddlEntities.SelectedIndex &amp;gt; 0)&lt;br /&gt;        {&lt;br /&gt;            lbEntityProperties.DataSource = GetPropertiesAndDataTypes(ddlEntities.SelectedValue);&lt;br /&gt;            lbEntityProperties.DataTextField = &lt;span class=&quot;str&quot;&gt;&quot;Value&quot;&lt;/span&gt;;&lt;br /&gt;            lbEntityProperties.DataValueField = &lt;span class=&quot;str&quot;&gt;&quot;Key&quot;&lt;/span&gt;;&lt;br /&gt;            lbEntityProperties.DataBind();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Product&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; _productId;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _name;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt;? _makeFlag;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; DateTime _selStartDate;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; DateTime? _selEndDate;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;? _daysToManufacture;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; ProductId&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _productId; }&lt;br /&gt;        set { _productId = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _name; }&lt;br /&gt;        set { _name = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt;? MakeFlag&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _makeFlag; }&lt;br /&gt;        set { _makeFlag = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; DateTime SelStartDate&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _selStartDate; }&lt;br /&gt;        set { _selStartDate = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; DateTime? SelEndDate&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _selEndDate; }&lt;br /&gt;        set { _selEndDate = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;? DaysToManufacture&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _daysToManufacture; }&lt;br /&gt;        set { _daysToManufacture = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Product()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Contact&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _name;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;? _score;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt;? _isMember;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Contact()&lt;br /&gt;    { }&lt;br /&gt;        &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;? Score&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _score; }&lt;br /&gt;        set { _score = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _name; }&lt;br /&gt;        set { _name = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt;? IsMember&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _isMember; }&lt;br /&gt;        set { _isMember = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;PUBLIC&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Reflect type of nullable properties&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:DropDownList&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ddlEntities&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AutoPostBack&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;True&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnSelectedIndexChanged&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ddlEntities_SelectedIndexChanged&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;-- Select Entity --&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Contact&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Product&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListItem&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:DropDownList&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListBox&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;lbEntityProperties&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;258px&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;265px&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ListBox&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2007/08/reflect-underlying-type-of-nullable.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-1896385448668743400</guid><pubDate>Mon, 16 Jul 2007 14:54:00 +0000</pubDate><atom:updated>2007-07-17T10:16:11.374-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Ajax</category><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><title>Handle multiple asynchronous calls in Asp.Net Ajax complex scenarios</title><description>I have been developing an Ajaxed Asp.net application that has in some pages a heavy load of Ajax components implemented with multiple update panels containing controls that fires heavy load process in the server side. To obtain a responsive UI the challenge was that the user can initiates an Ajax request and while it is processed, can initiate another requests.&lt;br /&gt;Browsing the &lt;a href=&quot;http://ajax.asp.net/docs/overview/AJAXClientEvents.aspx&quot; target=&quot;_new&quot;&gt;ASP.NET AJAX Client Life-Cycle Events&lt;/a&gt; I found the next explanation of Event Order for Multiple Asynchronous Postbacks:&lt;br /&gt;&lt;blockquote&gt;&quot;The default behavior of asynchronous postbacks is that the most recent asynchronous postback takes precedence. If two asynchronous postbacks occur in sequence, and if the first postback is still being processed in the browser, &lt;strong&gt;the first postback is canceled&lt;/strong&gt;. If the first postback has been sent to the server, the server processes the second request when it arrives and does not return the first request.&quot;&lt;/blockquote&gt;&lt;br /&gt;This behavour &quot;last request wins&quot; prevents the implementation of a full process of multiple request. Googling I found &lt;a href=&quot;http://forums.asp.net/p/1108522/1701902.aspx#1701902&quot; target=&quot;_new&quot;&gt;this article&lt;/a&gt; thats use a queue and works fine with few Ajax components but freeze the browser in the heavy Ajax request scenario. With a little tweak in the code (commented below) now it works smoothly and can handle a set of continuous requests.&lt;br /&gt;WARNING: have precaution in scenarios with controls that depend of the result of the execution of another control.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;PUBLIC&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Head1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Untitled Page&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ScriptManager&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ScriptManager1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:ScriptManager&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnClick&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button1_Click&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnClick&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button2_Click&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Label&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Label&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OnClick&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button3_Click&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdateProgress1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AssociatedUpdatePanelID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel1&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;DisplayAfter&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                Updating panel1&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdateProgress3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AssociatedUpdatePanelID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel3&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;DisplayAfter&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                Updating panel3&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdateProgress2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AssociatedUpdatePanelID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UpdatePanel2&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;attr&quot;&gt;DisplayAfter&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                Updating panel2&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ProgressTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdateProgress&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;AlertDiv&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;AlertMessage&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;  &lt;br /&gt;    Sys.Application.add_load(ApplicationLoadHandler)&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; ApplicationLoadHandler(sender, args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; prm = Sys.WebForms.PageRequestManager.getInstance();&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!prm.get_isInAsyncPostBack())&lt;br /&gt;        {&lt;br /&gt;            prm.add_initializeRequest(InitializeRequest);&lt;br /&gt;            prm.add_endRequest(CompleteRequest);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;rem&quot;&gt;// initialize a queue&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; myQueue = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Array();&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; CompleteRequest(sender, args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(myQueue.length &amp;gt; 0)&lt;br /&gt;        {   &lt;span class=&quot;rem&quot;&gt;// Fire correspond event again of the item cached&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Original Code: &lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// $get(myQueue[0].id).click();&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Changed to:&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// var control = $get(myQueue[0]);&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// setTimeout(&#39;__doPostBack(\&#39;&#39; + control.name + &#39;\&#39;,\&#39;\&#39;)&#39;, 0);&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; control = $get(myQueue[0]);&lt;br /&gt;            setTimeout(&lt;span class=&quot;str&quot;&gt;&#39;__doPostBack(\&#39;&#39;&lt;/span&gt; + control.name + &lt;span class=&quot;str&quot;&gt;&#39;\&#39;,\&#39;\&#39;)&#39;&lt;/span&gt;, 0);&lt;br /&gt;            Array.removeAt(myQueue, 0);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; InitializeRequest(sender, args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; prm = Sys.WebForms.PageRequestManager.getInstance();&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (prm.get_isInAsyncPostBack())&lt;br /&gt;        {   &lt;span class=&quot;rem&quot;&gt;// If it&#39;s working on another request, cache the current item that cause the request&lt;/span&gt;&lt;br /&gt;            args.set_cancel(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Original Code:&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Array.add(myQueue, args.get_postBackElement());&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Changed to: &lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;rem&quot;&gt;// Array.add(myQueue, args.get_postBackElement().name);&lt;/span&gt;&lt;br /&gt;            Array.add(myQueue, args.get_postBackElement().name);&lt;br /&gt;        } &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(Sys) !== &lt;span class=&quot;str&quot;&gt;&quot;undefined&quot;&lt;/span&gt;) Sys.Application.notifyScriptLoaded();&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Button1_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        System.Threading.Thread.Sleep(2000);&lt;br /&gt;        Label1.Text = DateTime.Now.ToLongTimeString();&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Button2_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        System.Threading.Thread.Sleep(2000);&lt;br /&gt;        Label2.Text = DateTime.Now.ToLongTimeString();&lt;br /&gt;    }&lt;br /&gt;    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Button3_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        System.Threading.Thread.Sleep(2000);&lt;br /&gt;        Label3.Text = DateTime.Now.ToLongTimeString();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</description><link>http://martinolivarespick.blogspot.com/2007/07/handle-multiple-asynchronous-calls.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-5500477024976963630</guid><pubDate>Wed, 06 Jun 2007 23:30:00 +0000</pubDate><atom:updated>2007-07-31T09:46:53.894-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Sql Server</category><title>Optimized paging in queries over two or more tables using Sql Server 2005 functions</title><description>&lt;p&gt;&lt;span&gt;&lt;br /&gt;The default paging made by the ASP.Net controls that support pagination is based on the following steps: &lt;br /&gt;1) Receive the DataSource with the result of the query&lt;br /&gt;2) Based on the page size and the page selected by the user, it selects the records of the &quot;selected page&quot; to show, discarding the rest of the data. This pagination is highly expensive in terms of resources (greater traffic and data processing), when the volume of records on which the query is made is of a considerable size. &lt;br /&gt;For example, a user has 200 Orders in the database and a form with gridview that shows 10 records for each page. If he browse 10 grid pages, the amount of records transferred to gridview so that this pagine will be of 2000 (200 records by each selected page) whereas the shown amount indeed is of 100 records. That is that 1900 records are transferred only to be discarded, by all means that this waste exponentially increases with the amount of records that the query gives back. The &lt;A href=&quot;http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx&quot;&gt;example of custom paging&lt;/A&gt; which we can easily find in the Web, makes use of function ROW_NUMBER() of SQL Server 2005, and only is useful when the query is made on an single table. At the time of making queries on related tables function ROW_NUMBER() does not apply, since to a registry “father” (as the head of an order) would assign so many RowNumbers as “children” (order details) records have. Therefore, looking for the new functions of SQL Server 2005 to solve this problem, I found the DENSE_RANK() function that allows to obtain only one RowNumber by each registry “father” in a query over multiple tables. Thus, I developed an stored procedure for the AdventureWorks database that gives back a certain page of result of a query over Orders and its detail in optimized form, this can be useful when need populate paged hierarchical data like Orders &amp; Order Details and want make to do a single call to retrieve all data of a single page.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;U&gt;&lt;STRONG&gt;Stored procedure PagedOrders&lt;/STRONG&gt;&lt;/U&gt;&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;PROCEDURE&lt;/span&gt; [dbo].[PagedOrders]&lt;br /&gt;    @pagesize &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;,&lt;br /&gt;    @pageindex &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; &lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SET&lt;/span&gt; NOCOUNT &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; *  &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt;  DENSE_RANK() &lt;span class=&quot;kwrd&quot;&gt;OVER&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; Sales.SalesOrderHeader.SalesOrderID &lt;span class=&quot;kwrd&quot;&gt;DESC&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;Row&lt;/span&gt;,&lt;br /&gt;        Sales.SalesOrderHeader.SalesOrderID,&lt;br /&gt;        Sales.SalesOrderHeader.OrderDate,&lt;br /&gt;        Sales.SalesOrderHeader.DueDate, &lt;br /&gt;        Sales.SalesOrderHeader.PurchaseOrderNumber, &lt;br /&gt;        Sales.SalesOrderHeader.SubTotal,&lt;br /&gt;        Sales.SalesOrderDetail.OrderQty,&lt;br /&gt;        Sales.SalesOrderDetail.UnitPrice,&lt;br /&gt;        Sales.SalesOrderDetail.ProductID, &lt;br /&gt;        Sales.SalesOrderDetail.UnitPriceDiscount,&lt;br /&gt;        Sales.SalesOrderDetail.LineTotal,&lt;br /&gt;        Production.Product.Name&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;    Sales.SalesOrderDetail&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt;&lt;br /&gt;        Sales.SalesOrderHeader&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; Sales.SalesOrderDetail.SalesOrderID = Sales.SalesOrderHeader.SalesOrderID&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt;&lt;br /&gt;        Production.Product&lt;br /&gt;        &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; Sales.SalesOrderDetail.ProductID = Production.Product.ProductID&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;Result&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt;  &lt;span class=&quot;kwrd&quot;&gt;Row&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;between&lt;/span&gt; ((@pageindex - 1) * @pagesize + 1) &lt;span class=&quot;kwrd&quot;&gt;and&lt;/span&gt; (@pageindex * @pagesize) &lt;/pre&gt;&lt;br /&gt;&lt;/p&gt;</description><link>http://martinolivarespick.blogspot.com/2007/06/paginando-consultas-sobre-mas-de-una.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-6335770821872455659</guid><pubDate>Mon, 04 Jun 2007 23:57:00 +0000</pubDate><atom:updated>2007-07-31T10:31:21.990-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><title>Localization and UICulture=&quot;auto&quot; attribute</title><description>While develop an application that requires location in all its pages I follow these 3 steps:&lt;br /&gt;1) Develop the pages and generate the resources files (in VS2005 Tools Option --&gt; Local Generate Resource)&lt;br /&gt;2) Create a page where the user selects the language of the application, which is stored in a Session variable or Profile field or Database field.&lt;br /&gt;3) Apply the language selected to all requests in the Application_PreAcquireRequestState. &lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;br /&gt;culture = HttpContext.Current.Session[&lt;span class=&quot;str&quot;&gt;&quot;culture&quot;&lt;/span&gt;].ToString();&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentUICulture = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; System.Globalization.CultureInfo(culture);&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(culture);&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;When test the application I found that the changes of language were not reflected in the different pages. This is because the UICulture=&quot;auto&quot; attribute of the @Page directive in each page, added automatically in step 1, does that the initialization of the localization succeeds at page level overriding the language selected by the user that is applied in the Application_PreAcquireRequestState. The solve this problem follow the next steps: &lt;br /&gt;· Apply the default culture to all pages in web.config (using globalization tag)&lt;br /&gt;· Delete UICulture=&quot;auto&quot; attibute tags added when generating the resources files. &lt;br /&gt;&lt;br /&gt;To have a better notion of the execution order of events in a request you can read this &lt;a href=&quot;http://msdn2.microsoft.com/en-US/library/ms178473.aspx&quot;&gt;article&lt;/a&gt; or explore this &lt;a href=&quot;http://blog.krisvandermast.com/content/binary/ASP.NET-2.0-life-cycle.png&quot;&gt;graphic&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;br /&gt;· Globalization:&lt;a href=&quot;http://www.dasblonde.net/CategoryView,category,Globalization.aspx&quot;&gt;Das Blonde Blog&lt;/a&gt;&lt;br /&gt;· Profiles : &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/d8b58y5d.aspx&quot;&gt;MSDN2&lt;/a&gt;</description><link>http://martinolivarespick.blogspot.com/2007/06/localization-y-atributo-uicultureauto.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5386271279942260625.post-5309106429943748183</guid><pubDate>Mon, 04 Jun 2007 17:50:00 +0000</pubDate><atom:updated>2007-07-31T16:37:20.069-03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Asp.Net</category><title>Changing the Default Profile Provider</title><description>&lt;p&gt;&lt;span &gt;I confess that it had not research so much over Memberships, Roles and Profiles provider until arrived the hour to use them in a project. While installing the SQL Server database to give support to providers with the Aspnet_regsql.exe tool, it thought how the fields corresponding to each property would keep from a profile, “wishing” that it was not an only field that contains names and values for all properties. When finalizing the installation I verified that my desires did not become reality and I find a table with 3 fields, one that describes the properties (PropertyNames) and in the other two the values are stored (PropertyValuesString and PropertyValuesBinary)&lt;br /&gt;&lt;img src=&quot;http://tk.files.storage.msn.com/x1pGaF9qTMw4pCwe9gr41C85oIa4n3otZB9f1_Sp3UbWBBnujf4sCxqlEVt19d-r7-L0XLPoGerfCTQk2eW7U7rhwhegNuIffcoxWmzo3DVPR3d6MkyXJtd58sUXfnjpXhzj5z_q5ZWmoY&quot; /&gt;&lt;br /&gt;This way to store the profiles reduces the flexibility when needs make reports, changes in the fields or store profile fields in different tables. The essence of providers is offer a point of variation in certain parts of an application, protecting the application of the implementation of the selected provider (that is the code of the application is not sensible when selects any provider). Native Providers of framework 2.0 does not try to include an exhaustive functionality, but rather they solve the common topics that it can be need in an application and serve as reference for the development of new providers. Luckyly they exist providers for SQL Server that solves the mentioned problems. &lt;br /&gt;In &lt;a href=&quot;http://www.asp.net/downloads/sandbox/table-profile-provider-samples/&quot;&gt;Sandbox&lt;/a&gt; are available 2 Sql Server providers:&lt;br /&gt;&lt;strong&gt;· SqlTableProfileProvider:&lt;/strong&gt; it allows map each property of profile with a field of an unique table. &lt;br /&gt;&lt;strong&gt;· SqlStoredProcedureProfileProvider:&lt;/strong&gt; it allows map each property of profile with a parameter of a Stored Procedure and within this, we can map each parameter to any table. The configuration is quite simple, only requires to add the class of the profile provider in directory APP_CODE and modify the web.config so that utilize this.&lt;br /&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx&quot;&gt;How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only 24 lines of code&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;http://www.eggheadcafe.com/articles/20060529.asp&quot;&gt;Integrating Customized Roles, Membership and Profiles in ASP.NET 2.0 &lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/x28wfk74.aspx&quot;&gt;Creating the Application Services Database for SQL Server&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;</description><link>http://martinolivarespick.blogspot.com/2007/06/confieso-que-no-haba-investigado-mucho.html</link><author>noreply@blogger.com (Martín Olivares)</author><thr:total>0</thr:total></item></channel></rss>