<?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/"
	>

<channel>
	<title>A Better Way &#187; DataPager</title>
	<atom:link href="http://www.thejacklawson.com/index.php/tag/datapager/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thejacklawson.com</link>
	<description>Finding a better way to get things done, a technical journey</description>
	<lastBuildDate>Tue, 24 Aug 2010 21:10:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)</title>
		<link>http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/</link>
		<comments>http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 21:29:26 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[data source codebehind]]></category>
		<category><![CDATA[DataPager]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[paging]]></category>

		<guid isPermaLink="false">http://www.thejacklawson.com/?p=16</guid>
		<description><![CDATA[After eight (well, seven.. lunch) torturous hours, trying to figure out something so simple, that should have been so easy, I&#8217;m finally done. (Spoiler: skip to the bottom to figure out how to fix the paging-control-one-step-behind issue) My scenario: I had an IList of objects, populated via some nHibernate magic. How I got the data [...]]]></description>
			<content:encoded><![CDATA[<p>After eight (well, seven.. lunch) torturous hours, trying to figure out something so simple, that should have been so easy, I&#8217;m finally done. (Spoiler: skip to the bottom to figure out how to fix the paging-control-one-step-behind issue)</p>
<p>My scenario: I had an IList of objects, populated via some nHibernate magic. How I got the data isn&#8217;t the important thing; just mattered that I had an IList of some object that I needed to put into some kind of paged display. The tricky bit was doing it through the codebehind, rather than setting up an ObjectDataSource for it. I tried several different methods, but kept coming back to one solution: a ListView with the new DataPager control.</p>
<p>It should have been pretty easy; the the DataPager control isn&#8217;t terribly hard to set up. Just throw in the control, populate the ID, runat, pagesize, and pagedcontrolid (the control that it adds paging to). That was attached to a listview, with an id and runat, and it had a layout template, item template, and alternatingtemplate inside of it. It all looked something like:</p>
<div style="background-color: #bbb;"><!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">DataPager</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">ID</span><span style="color: blue;">=&#8221;dpDataPager&#8221;</span><br />
<span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;</span><br />
<span style="color: red;">PageSize</span><span style="color: blue;">=&#8221;5&#8243;</span><br />
<span style="color: red;">PagedControlID</span><span style="color: blue;">=&#8221;lvItems&#8221;&gt;</span></span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Fields</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">NextPreviousPagerField</span><span> </span><span style="color: red;">NextPageText</span><span style="color: blue;">=&#8221;next »&#8221;</span> <span style="color: red;">ShowFirstPageButton</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: red;">ShowLastPageButton</span><span style="color: blue;">=&#8221;false&#8221;</span> <span style="color: red;">ShowNextPageButton</span><span style="color: blue;">=&#8221;false&#8221;</span> <span style="color: red;">ShowPreviousPageButton</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: blue;">/&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">NumericPagerField</span> <span style="color: red;">ButtonCount</span><span style="color: blue;">=&#8221;10&#8243;/&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">NextPreviousPagerField</span> <span style="color: red;">PreviousPageText</span><span style="color: blue;">=&#8221;« previous&#8221;</span> <span style="color: red;">ShowFirstPageButton</span><span style="color: blue;">=&#8221;false&#8221;</span> <span style="color: red;">ShowLastPageButton</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: red;">ShowNextPageButton</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: red;">ShowPreviousPageButton</span><span style="color: blue;">=&#8221;false&#8221;</span> <span style="color: blue;">/&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Fields</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">DataPager</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">ListView</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">ID</span><span style="color: blue;">=&#8221;lvItems&#8221;</span><br />
<span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;</span><span style="color: blue;">&gt;</span></span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">LayoutTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">span</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;itemPlaceholder&#8221;</span> <span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;&gt;&lt;/</span><span style="color: #a31515;">span</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">LayoutTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ItemTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">li</span> <span style="color: red;">class</span><span style="color: blue;">=&#8221;even&#8221;&gt;</span><span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span># Eval(&#8220;Caption&#8221;) <span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">li</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">ItemTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">AlternatingItemTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;"> </span></span> <!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">li</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">class</span><span style="color: blue;">=&#8221;odd&#8221;&gt;</span><span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span>#<br />
Eval(&#8220;Caption&#8221;) <span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">li</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">AlternatingItemTemplate</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #a31515;">ListView</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span></p>
<p></mce></p>
<p></mce></div>
<p>And (the important bits) in my code behind:<br />
In the Page_Load, I had</p>
<p><!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">if</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><br />
(!IsPostBack)</span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>bind();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p>And after the Page_Load method, I had<br />
<!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p></mce><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">private</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">void</span> bind()</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: #2b91af;">IList</span>&lt;<span style="color: #2b91af;">Content</span>&gt; content;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">int</span> id = <span style="color: #2b91af;">Int32</span>.Parse(Request.QueryString[<span style="color: #a31515;">"id"</span>]);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: #2b91af;">FeatureValues</span><br />
fv = <span style="color: #2b91af;">FeatureValues</span>.AudioGuestBook;</span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>content = <span style="color: #2b91af;">ContentWrapper</span>.GetContent(id);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">lvItems<span>.DataSource = </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">content</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">lvItems<span>.DataBind();</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p>And all was fine, and it rendered nicely. Except when you clicked to change a page, that is.</p>
<p>From there, weirdness ensued; it was out of sync, always one step behind.  If you clicked page 2, nothing happened. If you then clicked page 3, it went to page 2. If you went back to 1, it went to 3&#8230; and so on.  This led to a wild chase through several hours and pots of coffee using Google, which finally led me to <a href="http://forums.asp.net/t/1215848.aspx">a forum post</a>.  And there the answer was! It suddenly became clear: a solution which was, in the end, rather simple, if a little obscure. I added:<br />
<!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p></mce><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">onpagepropertieschanging</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">=&#8221;lvItems_PagePropertiesChanging&#8221;</span></p>
<p class="MsoNormal">
<p>to the ListView in the .ascx file, and<br />
<!--[if gte mso 9]><xml><br />
<w :WordDocument><br />
</w><w :View>Normal</w><br />
<w :Zoom>0</w><br />
<w :PunctuationKerning /><br />
<w :ValidateAgainstSchemas /><br />
<w :SaveIfXMLInvalid>false</w><br />
<w :IgnoreMixedContent>false</w><br />
<w :AlwaysShowPlaceholderText>false</w><br />
<w :Compatibility><br />
<w :BreakWrappedTables /><br />
<w :SnapToGridInCell /><br />
<w :WrapTextWithPunct /><br />
<w :UseAsianBreakRules /><br />
<w :DontGrowAutofit /><br />
</w><br />
<w :BrowserLevel>MicrosoftInternetExplorer4</w></p>
<p></xml>< ![endif]--><!--[if gte mso 9]><xml><br />
<w :LatentStyles DefLockedState="false" LatentStyleCount="156"><br />
</w><br />
</xml>< ![endif]--><br />
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p></mce><mce :style>< !  /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">protected</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">void</span> lvItems_PagePropertiesChanging(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">PagePropertiesChangingEventArgs</span><br />
e)</span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">this</span>.dpDataPager.SetPageProperties(e.StartRowIndex,<br />
e.MaximumRows, <span style="color: blue;">false</span>);</span>
</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>bind();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal">
<p>in the codebehind. This caused a change in the page to update both the listview and the data shown &#8211; something that I had been trying to find in a handler for the paging control, rather than the listview.</p>
<p>So there you have it: How to get a paged listview by using a data source set in the codebehind.</mce></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em> </em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Del.icio.us"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Del.icio.us" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to digg"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to digg" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to reddit"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to reddit" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to reddit" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Technorati"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Technorati" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.newsvine.com/_wine/save?u=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;h=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Newsvine"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/newsvine.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Newsvine" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Newsvine" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Stumble Upon"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Stumble Upon" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Stumble Upon" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Bookmarks"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Bookmarks" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Live-MSN"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Live-MSN" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29&amp;url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to SlashDot"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/slashdot.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to SlashDot" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to SlashDot" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;t=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to FaceBook"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to FaceBook" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Twitter"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Twitter" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/&amp;title=ASP.NET+DataPaging+Control+with+Data+Sources+Set+in+the+Codebehind+%28Including+LINQ%29&amp;srcURL=http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Buzz"><img src="http://www.thejacklawson.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Buzz" alt="Add 'ASP.NET DataPaging Control with Data Sources Set in the Codebehind (Including LINQ)' to Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://www.thejacklawson.com/index.php/2008/07/aspnet-datapaging-control-with-data-sources-set-in-the-codebehind-including-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
