<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Solutionizing .NET &#187; SPMenuField</title>
	<atom:link href="http://solutionizing.net/tag/spmenufield/feed/" rel="self" type="application/rss+xml" />
	<link>http://solutionizing.net</link>
	<description>Random thoughts on custom development in SharePoint.</description>
	<lastBuildDate>Sat, 12 May 2012 03:45:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='solutionizing.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Solutionizing .NET &#187; SPMenuField</title>
		<link>http://solutionizing.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://solutionizing.net/osd.xml" title="Solutionizing .NET" />
	<atom:link rel='hub' href='http://solutionizing.net/?pushpress=hub'/>
		<item>
		<title>SPDataSource Mystery Modes: Webs &amp; ListOfLists</title>
		<link>http://solutionizing.net/2008/09/09/spdatasource-mystery-modes-webs-listoflists/</link>
		<comments>http://solutionizing.net/2008/09/09/spdatasource-mystery-modes-webs-listoflists/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 06:24:18 +0000</pubDate>
		<dc:creator>Keith Dahlby</dc:creator>
				<category><![CDATA[Object Model]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WebParts & Controls]]></category>
		<category><![CDATA[ListOfLists]]></category>
		<category><![CDATA[MenuTemplate]]></category>
		<category><![CDATA[SPDataSource]]></category>
		<category><![CDATA[SPDataSourceMode.ListOfLists]]></category>
		<category><![CDATA[SPDataSourceMode.Webs]]></category>
		<category><![CDATA[SPMenuField]]></category>

		<guid isPermaLink="false">http://solutionizing.wordpress.com/?p=21</guid>
		<description><![CDATA[Chris O&#8217;Brien is right: SPDataSource is quite handy. However, its documentation leaves something to be desired. In particular, there aren&#8217;t any examples (that I can find) of how to use the Webs and ListOfLists SPDataSourceModes. It turns out that the result sets map to a subset of properties (both internal and public) of SPWeb and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=solutionizing.net&#038;blog=3982353&#038;post=21&#038;subd=solutionizing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointnutsandbolts.com/">Chris O&#8217;Brien</a> is right: <a title="SPDataSource - every SharePoint developer's friend (part 1)" href="http://www.sharepointnutsandbolts.com/2008/06/spdatasource-every-sharepoint-developer.html">SPDataSource</a> is quite handy. However, its documentation leaves something to be desired. In particular, there aren&#8217;t any examples (that I can find) of how to use the Webs and ListOfLists <a title="SPDataSourceMode Enumeration" href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spdatasourcemode.aspx">SPDataSourceMode</a>s. It turns out that the result sets map to a subset of properties (both internal and public) of SPWeb and SPList, respectively—but prepended with &#8220;__sp&#8221;. An easy way to see all available fields is to bind the data source to an <code>asp:GridView</code> with auto-generated columns:</p>
<pre>&lt;WSS:SPDataSource runat="server" ID="dsWebs" DataSourceMode="Webs" /&gt;
&lt;asp:GridView runat="server" ID="grdWebs" DataSourceID="dsWebs" AutoGenerateColumns="True"&gt;
    &lt;RowStyle VerticalAlign="Top" /&gt;
&lt;/asp:GridView&gt;
&lt;WSS:SPDataSource runat="server" ID="dsLists" DataSourceMode="ListOfLists" /&gt;
&lt;asp:GridView runat="server" ID="grdLists" DataSourceID="dsLists" AutoGenerateColumns="True"&gt;
    &lt;RowStyle VerticalAlign="Top" /&gt;
&lt;/asp:GridView&gt;</pre>
<p>For easy reference, I&#8217;ve put together a complete list of fields here:<br />
<a title="SPDataSource Fields for Webs &amp; ListsOfLists" href="http://solutionizing.net/spdatasource-fields-for-webs-listsoflists/">SPDataSource Fields for Webs &amp; ListsOfLists</a></p>
<p>Note that SharePoint Designer&#8217;s live preview of the grid shows extra columns (for Webs: __spAlerts, __spAllProperties, __spAllUsers, etc) that aren&#8217;t included in the rendering outside of Designer.</p>
<h2>SPDataSourceMode.Webs Example</h2>
<p>A list of fields is all well and good, but what can we do with it? Suppose we want an easy way to access our favorite settings pages for our subwebs. A contrived example, perhaps, but it will serve its purpose. We start with our data source:</p>
<pre>&lt;WSS:SPDataSource runat="server" ID="dsWebs"
  DataSourceMode="Webs" IncludeHidden="true"/&gt;</pre>
<p>Next, we&#8217;ll define a MenuTemplate of the site settings shortcuts we want available. %URL% is a token we&#8217;ll define in our SPMenuField.</p>
<pre>&lt;WSS:MenuTemplate runat="server" ID="WebMenu" CompactMode="true"&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Create"
    ClientOnClickNavigateUrl="%URL%/_layouts/create.aspx" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Site Settings"
    ClientOnClickNavigateUrl="%URL%/_layouts/settings.aspx" /&gt;
  &lt;WSS:MenuSeparatorTemplate runat="server" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="People and groups"
    ClientOnClickNavigateUrl="%URL%/_layouts/people.aspx" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Advanced permissions"
    ClientOnClickNavigateUrl="%URL%/_layouts/user.aspx" /&gt;
  &lt;WSS:MenuSeparatorTemplate runat="server" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Site libraries and lists"
    ClientOnClickNavigateUrl="%URL%/_layouts/mcontent.aspx" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Sites and workspaces"
    ClientOnClickNavigateUrl="%URL%/_layouts/mngsubwebs.aspx" /&gt;
  &lt;WSS:MenuItemTemplate runat="server" Text="Site features"
    ClientOnClickNavigateUrl="%URL%/_layouts/ManageFeatures.aspx" /&gt;
 &lt;WSS:MenuItemTemplate runat="server" Text="Delete this site"
    ClientOnClickNavigateUrl="%URL%/_layouts/deleteweb.aspx" /&gt;
&lt;/WSS:MenuTemplate&gt;</pre>
<p>And finally, a simple SPGridView with a link and menu for our site, with an extra column just for good measure:</p>
<pre>&lt;WSS:SPGridView runat="server" ID="spGrdWebs"
  DataSourceID="dsWebs" AutoGenerateColumns="false"&gt;
  &lt;Columns&gt;
    &lt;WSS:SPMenuField HeaderText="Site Title"
      NavigateUrlFields="__spDefaultUrl"
      NavigateUrlFormat="{0}"
      MenuTemplateId="WebMenu"
      TokenNameAndValueFields="URL=__spUrl,ID=__spID"
      TextFields="__spTitle" /&gt;
    &lt;WSS:SPBoundField HeaderText="Site Created"
      DataField="__spCreated" /&gt;
  &lt;/Columns&gt;
&lt;/WSS:SPGridView&gt;</pre>
<p>And our final result will look something like this:<br />
<a href="http://solutionizing.files.wordpress.com/2008/09/spdsmode-webs.png"><img class="alignnone size-full wp-image-118" title="SPDataSourceMode.Webs Example" src="http://solutionizing.files.wordpress.com/2008/09/spdsmode-webs.png?w=780" alt=""   /></a></p>
<p>So we&#8217;ve seen how to use SPDataSource in Webs mode, plus we have a code-free example of the often-overlooked SPMenuField. For what else could the Webs and ListOfLists modes be used?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/solutionizing.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/solutionizing.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/solutionizing.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/solutionizing.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/solutionizing.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=solutionizing.net&#038;blog=3982353&#038;post=21&#038;subd=solutionizing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://solutionizing.net/2008/09/09/spdatasource-mystery-modes-webs-listoflists/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26483382e3717e58e4c45d06c8ec351d?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">dahlbyk</media:title>
		</media:content>

		<media:content url="http://solutionizing.files.wordpress.com/2008/09/spdsmode-webs.png" medium="image">
			<media:title type="html">SPDataSourceMode.Webs Example</media:title>
		</media:content>
	</item>
	</channel>
</rss>
