<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx</link><description>I received an email question recently from a customer asking how they could dynamically load the LayoutTemplate for a ListView from a UserControl . I banged my head on this one for a while and eventually mailed our internal ASP.NET alias asking if someone</description><dc:language>en-GB</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>a-foton &amp;raquo; Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8775353</link><pubDate>Sat, 26 Jul 2008 14:10:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8775353</guid><dc:creator>a-foton &amp;raquo; Dynamically Loading ListView Templates</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog.a-foton.ru/2008/07/dynamically-loading-listview-templates/"&gt;http://blog.a-foton.ru/2008/07/dynamically-loading-listview-templates/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Always 英文技术文章参照（ 十一 ）{ UpdateTime:2008-7-27; } My article in the cnblogs</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8777089</link><pubDate>Sun, 27 Jul 2008 04:44:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8777089</guid><dc:creator>真见</dc:creator><description>&lt;p&gt;1.44个令人惊奇的Silverlight视频教程。2.ExpressionEncoder2VB.NETupdate3.HDViewforInternetExplore...&lt;/p&gt;
</description></item><item><title>Always 英文技术文章参照（ 十一 ）{ UpdateTime:2008-7-27; } My article in the cnblogs</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8777156</link><pubDate>Sun, 27 Jul 2008 05:21:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8777156</guid><dc:creator>cnblogs.com</dc:creator><description>&lt;p&gt;1. 44个令人惊奇的Silverlight视频教程。 2. Expression Encoder 2 VB.NET update 3. HD View for Internet Explorer HD&lt;/p&gt;
</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8834625</link><pubDate>Tue, 05 Aug 2008 21:31:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8834625</guid><dc:creator>Jordan Weber-Flink</dc:creator><description>&lt;p&gt;Does the newLayoutContainer's control collection act as a stack or a queue? It seems to me that the line&lt;/p&gt;
&lt;p&gt; &amp;nbsp; ListView1.Controls.RemoveAt(0);&lt;/p&gt;
&lt;p&gt;would remove your layoutTemplate when you load the ItemTemplate. &lt;/p&gt;
&lt;p&gt;???&lt;/p&gt;</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8840967</link><pubDate>Thu, 07 Aug 2008 15:27:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8840967</guid><dc:creator>MikeOrmond</dc:creator><description>&lt;p&gt;Hi Jordan. The LayoutTemplate acts as a container so items become children of the LayoutTemplate.&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;
</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8869771</link><pubDate>Fri, 15 Aug 2008 17:42:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8869771</guid><dc:creator>wuz</dc:creator><description>&lt;p&gt;I guess this applies to template classes as well and so &lt;/p&gt;
&lt;p&gt;namespace PresentationLayer&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class LayoutTemplate : ITemplate&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LiteralControl table = new LiteralControl(&amp;quot;&amp;lt;table&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;asp:PlaceHolder runat=\&amp;quot;server\&amp;quot; ID=\&amp;quot;ctl01$itemPlaceholder\&amp;quot; /&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.Controls.Add(table);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;will also say that itemPlaceholder cannot be found cause it changed.&lt;/p&gt;</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8872510</link><pubDate>Sat, 16 Aug 2008 23:53:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8872510</guid><dc:creator>wuz</dc:creator><description>&lt;p&gt;And i am afraid this solution is impossible when using direct databinding without a datasource&lt;/p&gt;</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8882775</link><pubDate>Thu, 21 Aug 2008 03:02:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8882775</guid><dc:creator>wuz</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thx again this really seems to be the only workaroun unfortuantely it fails when i use user controls or custom controls within the LayoutTemplate:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://forums.asp.net/p/1305569/2569260.aspx"&gt;http://forums.asp.net/p/1305569/2569260.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;greetings&lt;/p&gt;</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8883918</link><pubDate>Thu, 21 Aug 2008 10:51:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8883918</guid><dc:creator>MikeOrmond</dc:creator><description>&lt;p&gt;Wuz - I have it working with databinding with no DataSource. My databinding code looks like this:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;XDocument xdoc = XDocument.Load(Server.MapPath(&amp;quot;~/XmlFile.xml&amp;quot;));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;var query = from x in xdoc.Descendants(&amp;quot;book&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select new { id = (string)x.Attribute(&amp;quot;id&amp;quot;)};&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;ListView1.DataSource = query;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;ListView1.DataBind();&lt;/p&gt;
</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8884299</link><pubDate>Thu, 21 Aug 2008 13:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8884299</guid><dc:creator>wuz</dc:creator><description>&lt;p&gt;Hello mike,&lt;/p&gt;
&lt;p&gt;Thanks your entry really seems to be the only help for this topic. Unfortunately when I am using your suggestion it works for the first time when i am accessing the page, but not after the postback.&lt;/p&gt;
&lt;p&gt;There seems to be a problem in Begin Loadstate:&lt;/p&gt;
&lt;p&gt;An item placeholder must be specified on ListView 'lvList'. Specify an item placeholder by setting a control's ID property to &amp;quot;MyLayout$itemPlaceholder&amp;quot;. The item placeholder control must also specify runat=&amp;quot;server&amp;quot;.&lt;/p&gt;
&lt;p&gt; &amp;nbsp;bei System.Web.UI.WebControls.ListView.GetPreparedContainerInfo(Control outerContainer, Boolean isItem, Int32&amp;amp; placeholderIndex)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;bei System.Web.UI.WebControls.ListView.CreateItemsWithoutGroups(ListViewPagedDataSource dataSource, Boolean dataBinding, InsertItemPosition insertPosition, ArrayList keyArray)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;bei System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;bei System.Web.UI.WebControls.ListView.CreateChildControls()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;bei System.Web.UI.Control.EnsureChildControls()&lt;/p&gt;
&lt;p&gt;I have opened a thread with the complete sourcecode:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://forums.asp.net/p/1305569/2558209.aspx"&gt;http://forums.asp.net/p/1305569/2558209.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks again and kind regards&lt;/p&gt;</description></item><item><title>More on Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8887523</link><pubDate>Fri, 22 Aug 2008 14:31:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8887523</guid><dc:creator>Mike Ormond's Blog</dc:creator><description>&lt;p&gt;I got quite a few comments on my post on Dynamically Loading ListView Templates so rather than trying&lt;/p&gt;
</description></item><item><title>re: Dynamically Loading ListView Templates</title><link>http://blogs.msdn.com/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx#8887525</link><pubDate>Fri, 22 Aug 2008 14:32:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8887525</guid><dc:creator>MikeOrmond</dc:creator><description>&lt;p&gt;Just blogged an updated version. Mike&lt;/p&gt;
</description></item></channel></rss>