<?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>Inspector IT &#187; DNN</title>
	<atom:link href="http://inspectorit.com/tag/dnn/feed/" rel="self" type="application/rss+xml" />
	<link>http://inspectorit.com</link>
	<description>Inspector IT - Innovative Technologies</description>
	<lastBuildDate>Fri, 10 Sep 2010 12:00:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DNN Best Kept Secrets Part 1: DNN Paging Control</title>
		<link>http://inspectorit.com/tips-tricks/dnn-best-kept-secrets-part-1-dnn-paging-control/</link>
		<comments>http://inspectorit.com/tips-tricks/dnn-best-kept-secrets-part-1-dnn-paging-control/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 13:37:00 +0000</pubDate>
		<dc:creator>Webmaster</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[DNN]]></category>
		<category><![CDATA[DotNetNuke]]></category>
		<guid isPermaLink="false">http://wp.inspectorit.dev/company-news/dnn-best-kept-secrets-part-1-dnn-paging-control/</guid>
		<description><![CDATA[<p>If you are a developer and like me you mostly develop data driven applications, then I am sure that you have had to write a couple of paging functions and controls. I very rarely use the asp.net <em><strong>datagrid</strong></em> control as I find it bloated and harder to customize its UI. Instead&#8230;</p>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>If you are a developer and like me you mostly develop data driven applications, then I am sure that you have had to write a couple of paging functions and controls. I very rarely use the asp.net <em><strong>datagrid</strong></em> control as I find it bloated and harder to customize its UI. Instead I use the handy and much lighter weigth <strong><em>datalist</em></strong> and <em><strong>repeater</strong></em> controls.</p>
<p>Of course the drawback with the afore mentioned controls is that they do not come equipped with an integrated paging control as the <em><strong>datagrid</strong></em> does, but the folks at DotNetNuke did a fine job at remedying the situation: they built a re-usable Paging Control. If you are a DotNetNuke module developer, you should definitely consider using it instead of building your own. This is exactly what I did, and I am now sharing my experience since finding these &quot;nuggets&quot; of useful built-in functions and controls within <a href="http://www.dotnetnuke.com/">DotNetNuke</a> is more like &quot;treasure hunting&quot;!</p>
<p>First and foremost, I have to note that the DotNetNuke paging control does not manage the data, in fact it does not even bind to a source. All that the DotNetNuke Paging Control does is generate a paging interface, and builds the paging links based on some key data that you feed into it at run time. The information you provide control at runtime is as follows:</p>
<ul>
<li>TotalRecords      <br />Once you have filled your collection object, get its row count and feed it to this property of the control </li>
<li>PageSize      <br />Define the size of each page (i.e. the number of records you wish to display on each page) </li>
<li>CurrentPage      <br />Get the current page index and feed it into this property (i.e. Once the pager initiates the paging, you can get the pageindex from the querystring called CurrentPage) </li>
<li>Querystring      <br />If your module needs its own custom querystring parameters, feed them into this property, the paging links will append them for you so that your data continues to load normally) </li>
</ul>
<p>The following is a code example for filling the the properties mentioned above:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:8df0e4da-eb07-4fe7-bbca-88e1bc1623ad" class="wlWriterSmartContent">
<pre class="vb" name="code">ctlPagingControl.TotalRecords = TotalRecords
ctlPagingControl.PageSize = PageSize
ctlPagingControl.CurrentPage = PageIndex</pre>
</div>
<p>The following is a screen shot of the generated Paging Control:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DNNPaginControl" border="0" alt="DNNPaginControl" src="http://wp.inspectorit.dev/wp-content/uploads/2009/12/DNNPaginControl.gif" width="476" height="33" /> </p>
<h2>Putting it all together</h2>
<p>Let&#8217;s start by adding the control to your UI page. First we must register the WebControl assembly (DotNetNuke.UI.WebControls) at the top of your page, and then add the control to a location of the page of your choice. The code example below assumes you are adding this paging control below your datalist/repeater:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:e616f531-5a36-4bba-bda9-64cd67e8b268" class="wlWriterSmartContent">
<pre class="vb" name="code">&lt;%@ Register TagPrefix=&quot;dnn&quot; Namespace=&quot;DotNetNuke.UI.WebControls&quot; Assembly=&quot;DotNetNuke&quot; %&gt;
&lt;asp:Datalist ID=&quot;Datalist1&quot; runat=&quot;server&quot;&gt;&lt;/asp:Datalist&gt;
&lt;dnn:PagingControl id=&quot;PagingControl1&quot; runat=&quot;server&quot;&gt;&lt;/dnn:PagingControl&gt;</pre>
</div>
<p>The next (and last) thing to do is stitch the control to your data source.<br />
  <br />First let me explain that there are two ways (that I know of) you can page your data:</p>
<ol>
<li><strong>Via Stored Procedure or Data Access:<br />
      <br /></strong>This is the most labor intensive, but will give you better performance. Basically you page the data in the stored procedure itself by passing the PageIndex and the PageSize into it so that it return and fills your collection with just the rows that you need. </li>
<li><strong>Via Use the </strong><a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.pageddatasource.aspx"><strong>PagedDataSource</strong></a><strong> Class</strong>
<p>This class enables you to page the entire source with much less code, however, all the rows are fetched at each page request, regardless of which page you are on (Unless you do some additional data caching in your asp.net code, in which case you are ok).</p>
<p>For simplicity&#8217;s sake, the example I provide below implements this methodology. </li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:9ba7fc34-bccb-4d00-999e-bdd751722df5" class="wlWriterSmartContent">
<pre class="vb" name="code">Private Sub BindDatalist()
Dim PageSize = 20 'Display 20 items per page
'Get the currentpage index from the url parameter
If Request.QueryString(&quot;currentpage&quot;) IsNot Nothing Then
_CurrentPage = Request.QueryString(&quot;currentpage&quot;).ToString
Else
_CurrentPage = 1
End If
'Call you data layer and get the data you need to bind to the datalist
Dim objDataController As New YouDataController
Dim objCollection As List(Of YourObject) = objDataController.GetData()
'Fill the PagedDataSource object's datasource property with your collection
Dim objPagedDataSource As New PagedDataSource
objPagedDataSource.DataSource = objCollection
If Me.PageSize &gt; 0 Then
objPagedDataSource.PageSize = PageSize
objPagedDataSource.CurrentPageIndex = _CurrentPage - 1
objPagedDataSource.AllowPaging = True
End If
'Bind the datalist
dlWhoIsOnline.DataSource = objPagedDataSource
dlWhoIsOnline.DataBind()
'Show/hide the pager based on on the number of rows fetched vs pagesize
If PageSize = 0 OrElse objDataController.Count &lt;= PageSize Then
ctlPagingControlBottom.Visible = False
Else
ctlPagingControlBottom.Visible = True
With ctlPagingControlBottom
.TotalRecords = objDataController.Count
.PageSize = PageSize
.CurrentPage = _CurrentPage
.TabID = TabId
End With
End If
End Sub</pre>
</div>
<p>You should now be able to run your project and test the paging control.</p>
<p>Feel free to post your comments below if you need additional information.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://inspectorit.com/tips-tricks/dnn-best-kept-secrets-part-1-dnn-paging-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
