<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/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>Tips &amp; Tricks</title><link>http://forums.asp.net/53.aspx</link><description>Cool code and exciting examples, provided by our members.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/3403460.aspx</link><pubDate>Mon, 14 Sep 2009 11:36:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3403460</guid><dc:creator>mahesh81</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3403460.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3403460</wfw:commentRss><description>&lt;p&gt;refer this articel&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://maheshde.blogspot.com/2009/09/how-to-implement-custom-paging-using.html"&gt;http://maheshde.blogspot.com/2009/09/how-to-implement-custom-paging-using.html&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/3382066.aspx</link><pubDate>Wed, 02 Sep 2009 03:02:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3382066</guid><dc:creator>WebBot Tech</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3382066.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3382066</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I&amp;#39;m still new to ASP.Net. I&amp;#39;m using VWD&amp;#39;08 (.Net 3.5) and C#.&amp;nbsp;I&amp;#39;m trying to create a landing page for several people. I want to use one master page with fields that fill in based on a database that I have already created. The idea is that when someone enters [site.com]/user the fields will display their contact info and site links based on the label I add to the content placeholder. &lt;/p&gt;
&lt;p&gt;Also, when I get a new member, all I have to do is enter their info in my database. This will help keep me from creating many duplicate pages.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;is a GridView or DetailsView the right control to use?&lt;/p&gt;</description></item><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/3379341.aspx</link><pubDate>Mon, 31 Aug 2009 19:00:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3379341</guid><dc:creator>obwill74</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3379341.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3379341</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;The part I was missing was setting the new page index during the PageIndexChanging routine of the grid view prior to calling the CreateTable routine.&lt;/p&gt;
&lt;p&gt;Me.GridView1.PageIndex = e.NewPageIndex&lt;/p&gt;</description></item><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/3379230.aspx</link><pubDate>Mon, 31 Aug 2009 17:53:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3379230</guid><dc:creator>chorofonfilo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3379230.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3379230</wfw:commentRss><description>&lt;p&gt;It worked for me doing a little changes of the following methods, i am not sure tho if its how the author of the post meant to make this work or its completely correct according to some programmatical standars.&lt;/p&gt;&lt;p&gt;Imports System.Data&lt;br /&gt;Imports System.Data.SqlClient&lt;/p&gt;&lt;p&gt;Public Class MyTableAdapter&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dt As DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim vic As Integer &amp;#39;virtual item count&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub New(ByVal dtp As DataTable, ByVal vicp As Integer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = dtp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vic = vicp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;returns the filled datatable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Function GetData() As DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return dt&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;returns the number of records&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Function VirtualItemCount() As Integer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return vic&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;#39;this also returns the datatable but the ODS needs it for paging purposes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Function GetData(ByVal startRow As Integer, ByVal maxRows As Integer) As DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return dt&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;/p&gt;&lt;p&gt;----&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Imports System.Data&lt;br /&gt;Imports System.Data.SqlClient&lt;/p&gt;&lt;p&gt;Public Class MyGridViewFiller&lt;/p&gt;&lt;p&gt;Private dt As New DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private vic As Integer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private callerpage As Page&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private gid As String&lt;/p&gt;&lt;p&gt;Public Sub CreateCuteLittleTable(ByVal pagep As Page, ByVal gidp As String, _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal regini As Integer, ByVal numregporpag As Integer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;This is the stored procedure which retrieves the records based on the following parameters&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dap As New SqlDataAdapter(&amp;quot;damenordenesdea&amp;quot;, bd.globalcn) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dap.SelectCommand.CommandType = CommandType.StoredProcedure&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Initial Record from which the rest of records will be displayed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dap.SelectCommand.Parameters.Add(&amp;quot;@nregini&amp;quot;, SqlDbType.Int).Value = regini&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Number of Records per page&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dap.SelectCommand.Parameters.Add(&amp;quot;@nregporpag&amp;quot;, SqlDbType.Int).Value = numregporpag&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Retrieve the number of total records spit out by the query&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; dap.SelectCommand.Parameters.Add(&amp;quot;@nregis&amp;quot;, SqlDbType.Int).Direction = ParameterDirection.Output&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dap.Fill(dt)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Set the vic variable with the total amount of records to display&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vic = dap.SelectCommand.Parameters(&amp;quot;@nregis&amp;quot;).Value&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;lets store the page we are in and the gridviewid of that page&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; callerpage = pagep&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gid = gidp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FillGridView()&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Protected Sub ods_ObjectCreating(ByVal sender As Object, ByVal e As ObjectDataSourceEventArgs)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; e.ObjectInstance = New MyTableAdapter(dt, vic)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub FillGridView()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;First let&amp;#39;s make a GridView object that hold the GridView&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim gv As GridView = CType(callerpage.FindControl(gid), GridView)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Then create an ObjectDateSource object programmatically&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ods As New ObjectDataSource&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;setting the necessary properties (these will interact with our TableAdapter !)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.ID = &amp;quot;ods&amp;quot; &amp;amp; gid&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;the paging of ODS depends on the paging of the GridView&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.EnablePaging = gv.AllowPaging&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.TypeName = &amp;quot;MyTableAdapter&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.SelectMethod = &amp;quot;GetData&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.SelectCountMethod = &amp;quot;VirtualItemCount&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.StartRowIndexParameterName = &amp;quot;startRow&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.MaximumRowsParameterName = &amp;quot;maxRows&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.EnableViewState = True&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Instead of calling the parameterless constructor of our TableAdapter, I&amp;#39;m going &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;to hook up on the ods.ObjectCreating event to supply my own TableAdapter (WITH constructor parameters)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;the following line is the &amp;quot;hook up&amp;quot; declaration&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;#39;this means that at the object creating event, the CLR is going to jump to my event handler (ods_ObjectCreating)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddHandler ods.ObjectCreating, New ObjectDataSourceObjectEventHandler(AddressOf ods_ObjectCreating)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;after that, we only need to&amp;nbsp; bind the ODS to the GridView&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gv.DataSource = ods&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gv.DataBind()&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/p&gt;&lt;p&gt;End Class&lt;/p&gt;&lt;p&gt;---&lt;/p&gt;&lt;p&gt;The Default.aspx page which will alocate the gridview&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load&lt;/p&gt;&lt;p&gt;If Not Page.IsPostback Then&lt;/p&gt;&lt;p&gt;Dim gvf As New MyGridViewFiller&lt;br /&gt;gvf.CreateCuteLittleTable(Me.Page, Me.GridView1.ID, 0, 10)&lt;/p&gt;&lt;p&gt;End If&lt;br /&gt;&lt;/p&gt;&lt;p&gt;End Sub&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.GridView1.PageIndex = e.NewPageIndex&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim gvf As New MyGridViewFiller&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;the method pass the page, the gridviewid, the inital record number to be displayed according to the actual gridview pageindex, &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and the amount of records per page &amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gvf.CreateCuteLittleTable(Me.Page, Me.GridView1.ID, ((Me.GridView1.PageIndex + 1) * Me.GridView1.PageSize)&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Me.GridView1.PageSize), Me.GridView1.PageSize)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;End Class&lt;/p&gt;&lt;p&gt;---&lt;/p&gt;&lt;p&gt;This is the storedprocedure which handles the paging, the example works with the table orders from the Northwind Database.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;create procedure damenordenesdea&lt;br /&gt;@nregini int,---number of the starting record to be displayed&lt;br /&gt;@nregporpag int,---number of records to be displayed per gridview page&lt;br /&gt;@nregis int output ---total number of the records resulted from the query&lt;br /&gt;as&lt;br /&gt;Declare @msql nvarchar(500)&lt;br /&gt;set @msql=N&amp;#39;SELECT @nregis=count(*) from orders SELECT top &amp;#39; + convert(varchar,@nregporpag) + &amp;#39; * FROM orders &lt;br /&gt;WHERE orderid &lt;br /&gt;NOT IN&lt;br /&gt;(SELECT TOP &amp;#39; + convert(varchar,@nregini)&amp;nbsp; + &amp;#39; orderid FROM orders order by orderid asc)&lt;br /&gt;order by orderid asc&amp;#39;&lt;br /&gt;exec sp_executesql @msql,N&amp;#39;@nregini int,@nregporpag int,@nregis int output&amp;#39;,@nregini=@nregini,@nregporpag=@nregporpag,@nregis=@nregis output&lt;/p&gt;&lt;p&gt;I have a working example if you want to test it, just let me know and i will send it to you.&lt;/p&gt;&lt;p&gt;I hope it helped you.&lt;/p&gt;&lt;p&gt;Choro.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/3379050.aspx</link><pubDate>Mon, 31 Aug 2009 16:18:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3379050</guid><dc:creator>obwill74</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3379050.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3379050</wfw:commentRss><description>&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Verdana&amp;#39;, &amp;#39;sans-serif&amp;#39;;COLOR:black;FONT-SIZE:9pt;"&gt;You were right, this was very helpful. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Verdana&amp;#39;, &amp;#39;sans-serif&amp;#39;;COLOR:black;FONT-SIZE:9pt;"&gt;I am having one issue though; I can not seem to pass the page number through from my aspx code behind page to the class with the data retrieval routine. Can you provide any information to help with that?&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Re: Paging recordsets from various databases</title><link>http://forums.asp.net/thread/3286612.aspx</link><pubDate>Fri, 10 Jul 2009 18:31:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3286612</guid><dc:creator>chorofonfilo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3286612.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3286612</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;keithoon:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi, I tried to convert it to VB and is facing some problem. Are you able to help?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;How to convert the below to VB?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;ods.ObjectCreating += &lt;span class="kwd"&gt;&lt;span class="" style="COLOR:#0000ff;FONT-FAMILY:;"&gt;new&lt;/span&gt;&lt;/span&gt; ObjectDataSourceObjectEventHandler(ods_ObjectCreating);&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I got stuck at this as well,&amp;nbsp;but i found out the equivalent expression for anyone interested.&lt;/p&gt;
&lt;p&gt;&amp;#39;After your create the ods_ObjectCreating event Handler(as referred by the post of our friend):&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;&amp;nbsp;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;Protected&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;Sub&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; ods_ObjectCreating(&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;ByVal&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; sender &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;As&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;Object&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;, &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;ByVal&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; e &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;As&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; ObjectDataSourceEventArgs)&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;&amp;nbsp;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;e.ObjectInstance&amp;nbsp;=&lt;/span&gt;&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; MyTableAdapter(_dt, _vic)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;End&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;Sub&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;
&lt;p&gt;&amp;#39;The hook to it should be set this way on the FillGrid Method&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;AddHandler&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; ods.ObjectCreating, &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;New&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; ObjectDataSourceObjectEventHandler(&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;AddressOf&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; ods_ObjectCreating)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;and thats it, i hope this was helpful to you all.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;Best Regards.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Choro.&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;</description></item><item><title>Re: Paging recordsets from various databases</title><link>http://forums.asp.net/thread/3253523.aspx</link><pubDate>Tue, 23 Jun 2009 17:05:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3253523</guid><dc:creator>tijoen</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3253523.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3253523</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thanks, it helped me too.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Paging recordsets from various databases</title><link>http://forums.asp.net/thread/3205222.aspx</link><pubDate>Tue, 02 Jun 2009 16:17:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3205222</guid><dc:creator>binsys</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3205222.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3205222</wfw:commentRss><description>&lt;p&gt;Yes, yes, yes, I will thank you!!!!! - THANK GOD somebody wrote this down. I have been searching for days with this exact problem....&lt;/p&gt;</description></item><item><title>Re: Paging recordsets from various databases</title><link>http://forums.asp.net/thread/2103589.aspx</link><pubDate>Fri, 11 Jan 2008 08:31:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2103589</guid><dc:creator>keithoon</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2103589.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=2103589</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi, I tried to convert it to VB and is facing some problem. Are you able to help?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;How to convert the below to VB?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;ods.ObjectCreating += &lt;span class="kwd"&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; ObjectDataSourceObjectEventHandler(ods_ObjectCreating);&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Paging recordsets from various databases</title><link>http://forums.asp.net/thread/1639555.aspx</link><pubDate>Tue, 27 Mar 2007 18:37:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1639555</guid><dc:creator>victorhvalle</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1639555.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1639555</wfw:commentRss><description>&lt;p&gt;Using the method of our friend the clown I've developed an "Enhanced Grid View"... &lt;/p&gt;&lt;p&gt;I had several problems because my business objects return IList instead of nasty DataTables so my adapter has little modifications. Just read the code and you'll can modify it to accept any Collection your business use. With this control the only thing you need to do is to add:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;%@ Register TagPrefix="[A prefix like 'netsux']" Namespace="[The namespace where EnhancedGridView class is located]" Assembly="[Your assembly]" %&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;in your aspx file and to replace the &amp;lt;asp:GridView ...&amp;gt; tag with &amp;lt;prefix:EnhancedGridView ...&amp;gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;I'm not a nice person as him but however here's my code... &lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;   // This class must be located whenever you want  &lt;br /&gt;    public class VirtualItemCountTableAdapter {&lt;br /&gt;        private IList data;&lt;br /&gt;        private Int32 virtualItemCount;&lt;br /&gt;&lt;br /&gt;        public VirtualItemCountTableAdapter(IList data, Int32 virtualItemCount) {&lt;br /&gt;            this.data = data;&lt;br /&gt;            this.virtualItemCount = virtualItemCount;&lt;br /&gt;        }&lt;br /&gt;        public IList GetData() {&lt;br /&gt;            return data;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Int32 GetVirtualItemCount() {&lt;br /&gt;            return virtualItemCount;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public IList GetData(int startRow, int maxRows) {&lt;br /&gt;            return data;&lt;br /&gt;        }&lt;br /&gt;    } &lt;br /&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;    public class&lt;/span&gt; EnhancedGridView : GridView {
        &lt;span class="kwd"&gt;private&lt;/span&gt; IList pagedList;
        &lt;span class="kwd"&gt;private&lt;/span&gt; Int32 virtualItemCount;

        &lt;span class="kwd"&gt;public override&lt;/span&gt; Object DataSource {
            &lt;span class="kwd"&gt;get&lt;/span&gt; {
                &lt;span class="kwd"&gt;return base&lt;/span&gt;.DataSource;
            }
            &lt;span class="kwd"&gt;set&lt;/span&gt; {
                &lt;span class="kwd"&gt;if&lt;/span&gt; (&lt;span class="kwd"&gt;value is&lt;/span&gt; IList) {
                    pagedList = &lt;span class="kwd"&gt;value as&lt;/span&gt; IList;

                    ObjectDataSource ods = &lt;span class="kwd"&gt;new&lt;/span&gt; ObjectDataSource();

                    ods.ID = &lt;span class="st"&gt;"ods_"&lt;/span&gt; + &lt;span class="kwd"&gt;this&lt;/span&gt;.ID;

                    ods.EnablePaging = &lt;span class="kwd"&gt;this&lt;/span&gt;.AllowPaging;
                    ods.TypeName = &lt;span class="st"&gt;"VirtualItemCountTableAdapter"&lt;/span&gt;; &lt;span class="cmt"&gt;// This must be the full name of the class&lt;/span&gt;
                    ods.SelectMethod = &lt;span class="st"&gt;"GetData"&lt;/span&gt;;
                    ods.SelectCountMethod = &lt;span class="st"&gt;"GetVirtualItemCount"&lt;/span&gt;;
                    ods.StartRowIndexParameterName = &lt;span class="st"&gt;"startRow"&lt;/span&gt;;
                    ods.MaximumRowsParameterName = &lt;span class="st"&gt;"maxRows"&lt;/span&gt;;
                    ods.EnableViewState = &lt;span class="kwd"&gt;false&lt;/span&gt;;

                    ods.ObjectCreating += &lt;span class="kwd"&gt;new&lt;/span&gt; ObjectDataSourceObjectEventHandler(ods_ObjectCreating);

                    &lt;span class="kwd"&gt;base&lt;/span&gt;.DataSource = ods;
                } &lt;span class="kwd"&gt;else&lt;/span&gt; {
                    &lt;span class="kwd"&gt;base&lt;/span&gt;.DataSource = &lt;span class="kwd"&gt;value&lt;/span&gt;;
                }
            }
        }

        &lt;span class="kwd"&gt;private void&lt;/span&gt; ods_ObjectCreating(Object sender, ObjectDataSourceEventArgs e) {
            e.ObjectInstance = &lt;span class="kwd"&gt;new&lt;/span&gt; VirtualItemCountTableAdapter(pagedList, virtualItemCount);
        }

        &lt;span class="kwd"&gt;public&lt;/span&gt; Int32 VirtualItemCount {
            &lt;span class="kwd"&gt;get&lt;/span&gt; {
                &lt;span class="kwd"&gt;return&lt;/span&gt; virtualItemCount;
            }
            &lt;span class="kwd"&gt;set&lt;/span&gt; {
                virtualItemCount = &lt;span class="kwd"&gt;value&lt;/span&gt;;
            }
        }
    }&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;If problems persist... change to Java &lt;img src="http://forums.asp.net/emoticons/emotion-5.gif" alt="Wink" /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Paging recordsets from various databases</title><link>http://forums.asp.net/thread/1603825.aspx</link><pubDate>Sun, 04 Mar 2007 01:43:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1603825</guid><dc:creator>Erwin@ODS</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1603825.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1603825</wfw:commentRss><description>&lt;p&gt;I said in the article I would post another article that points to some great stuff about paging records from various databases.&lt;/p&gt;
&lt;p&gt;You'll find my new article here : &lt;a href="http://forums.asp.net/thread/1603489.aspx"&gt;http://forums.asp.net/thread/1603489.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Have fun !&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Erwin&lt;/p&gt;</description></item><item><title>Re: Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/1574954.aspx</link><pubDate>Mon, 12 Feb 2007 16:58:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1574954</guid><dc:creator>mru22</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1574954.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1574954</wfw:commentRss><description>&lt;p&gt;I am a little confused on how I would apply a search method where I pass numerou parameters.&amp;nbsp; Currently I am using the object datasourece with the select method and the select count methods so i can provide sorting and paging.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;On the following two lines,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;_dt = //some code to create the 10-row DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_vic = //some code to calculate the total rows of the table (30.000)&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What would be some sample code that would calculate the 10 row table or the total ?&lt;/p&gt;</description></item><item><title>Custom Paging and the GridView ASP.NET 2.0 - you'll thank me for this !</title><link>http://forums.asp.net/thread/1554769.aspx</link><pubDate>Tue, 30 Jan 2007 06:28:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1554769</guid><dc:creator>Erwin@ODS</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1554769.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1554769</wfw:commentRss><description>&lt;p&gt;Ok, because I think all you clods have the same problem as a clod like me, the following post can really be helpfull, I think.&lt;/p&gt;
&lt;p&gt;Remember the DataGrid in ASP.NET 1.x, and it's VirtualItemCount property ? If you wanted the DataGrid to display a custom pager row, you just had to set to "AllowCustomPaging" to true, bind a datasource to it, and supply a number to the VirtualItemCount property. Et voilà : the pager bar came up automatically ! Magic !&lt;/p&gt;
&lt;p&gt;With ASP.NET 2.0 a new kid was in town : the GridView. Great stuff !! But, wait a minute, it isn't that easy to display a custom pager row !&lt;br /&gt;I looked and looked and searched and read quite some stuff, and finally I came up with the following solution. Now, I could very well keep this just to myself, but since I'm such a nice person, I'll share it with all you clowns..&lt;/p&gt;
&lt;p&gt;Suppose that you have the following situation :&lt;br /&gt;- you have a GridView, and you want only 10 records to display at a time&lt;br /&gt;- you have a table which contains 30.000 records&lt;br /&gt;- you don't want to use the default paging of the GridView, because this will retrieve all 30.000 records at every round trip.&lt;br /&gt;- you have figured out a way to retrieve only 10 records at a time (I'm not going into details of this, maybe in a later post, I found some great stuff to do just that !)&lt;/p&gt;
&lt;p&gt;The only thing you need is to have the GridView display a pager row. And there, you're stuck. Because the GridView does NOT have a VirtualItemCount property, it only has a PageCount property, but that's read only !&lt;/p&gt;
&lt;p&gt;A solution could be to do all the work declaratively at design time. In fact, all the tutorials and posts that you'll read show you how to do this declaratively, with the help of a ObjectDataSource and a TableAdapter. &lt;br /&gt;But that is at design time ! &lt;/p&gt;
&lt;p&gt;What if you need to bind the GridView at run-time, i.e. programmatically ? That's where the real problem lies !&lt;/p&gt;
&lt;p&gt;In order to solve this problem, you have to know 2 things :&lt;br /&gt;- the ObjectDataSource (=ODS) needs to have the name of a class that will handle the data requests. When you do this by declaration, it's the TableAdapter that takes care of that. So, part of the solution is to create our own TableAdapter !&lt;br /&gt;- on the other hand, the ODS at run-time creates&amp;nbsp; an instance of that class with a parameterless constructor. You can shout "Yikes !" twice here : first, because the data-handling object can not be instantiated (constructed) with any parameters, and two : it can not be accessed because it's shielded in the ODS. So, how can you feed your precious 10-record table to that data-object ? Well, you can't...&lt;/p&gt;
&lt;p&gt;Unless....&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;You do the following things :&lt;br /&gt;1. Create your own TableAdapter that takes care of providing the data. Don't worry, if you're only interested in displaying records, it's done in a snap.&lt;br /&gt;2. Create a event-handler that takes control over what kind of datasource object is created and handed over to the ODS. Again, this only takes some lines of code. &lt;/p&gt;
&lt;p&gt;AND YOU'RE DONE !&lt;/p&gt;
&lt;p&gt;Ok, let's get down to it.&lt;/p&gt;
&lt;p&gt;First, let's create our own TableAdapter. When it's only for data-displaying, our TableAdapter should contain only 3 things :&lt;br /&gt;- a method to supply the data (e.g. a datatable) (in our example, only 10 rows)&lt;br /&gt;- a method to supply the total of numbers of the table (30.000)&lt;br /&gt;- a method to supply the data with 2 parameters : one for setting&amp;nbsp; the Start Row Index, the other for setting the Maximum Rows (actually, I'm not going to do anything with this, because I already have my DataTable with the right records ! Still, the method has to be there !)&lt;/p&gt;
&lt;p&gt;Also, I'm going to write a constructor of this class that will take as parameters our cute little datatable and the total number of rows, which I'll will call "VirtualItemCount" (to salute the earlier DataGrid)&lt;/p&gt;
&lt;p&gt;This is how it could look like :&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal class MyTableAdapter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private DataTable _dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int _vic;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;//this is the constructor that takes as parameters a cute little datatable&lt;br /&gt;&amp;nbsp;// with the right 10 records, an an integer vic = virtualitemcount&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MyTableAdapter(DataTable dt, int vic)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dt = dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _vic = vic;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;//this returns the datatable (10 records)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public DataTable GetData()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;//this returns the total number of records in the table (30.000)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int VirtualItemCount()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _vic;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;//this also returns the datatable (10 records) but the ODS needs it for paging purposes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public DataTable GetData(int startRow, int maxRows)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;br /&gt;The next thing we'll do is to create a class which will handle the creation of a datatable, and hand it over to another function to feed the GridView&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;internal class MyGridViewFiller&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;//these fields are for storing the cute little datatable and the virtualitemcount&lt;br /&gt;&amp;nbsp;&amp;nbsp;private DataTable _dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;private int _vic;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;//these fields are for storing the calling page and the GridViewID&lt;br /&gt;&amp;nbsp;&amp;nbsp;private Page _page;&lt;br /&gt;&amp;nbsp;&amp;nbsp;private string _id;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;public void CreateCuteLittleTable(Page Page, string GridViewID)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//here you create your cute little datatable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//and also you calculate the total number of rows&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_dt = //some code to create the 10-row DataTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_vic = //some code to calculate the total rows of the table (30.000)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//let's also store the page and the gridviewid&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_page = Page;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_id = GridViewID&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//call the GridView filler&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;FillGridView()&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void FillGridView()&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//First let's make an GridView object that hold the GridView&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;GridView gv = (GridView)_page.FindControl(_id);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Then create an ObjectDateSource object programmatically&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ObjectDataSource ods = new ObjectDataSource();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//setting the necessary properties (these will interact with our TableAdapter !)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.ID = "ods" + _id;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.EnablePaging = gv.AllowPaging; //the paging of ODS depends on the paging of the GridView&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.TypeName = "MyTableAdapter"; //be sure to prefix the namespace of your application !!! e.g. MyApp.MyTableAdapter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.SelectMethod = "GetData"; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.SelectCountMethod = "VirtualItemCount";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.StartRowIndexParameterName = "startRow";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.MaximumRowsParameterName = "maxRows";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods.EnableViewState = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//HERE IS THE TRICK !!!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//In stead of calling the parameterless constructor of our TableAdapter, I'm going &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//to hook up on the ods.ObjectCreating event to supply my own TableAdapter (WITH constructor parameters)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//the following line is the "hook up" declaration&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ods.ObjectCreating += new ObjectDataSourceObjectEventHandler(ods_ObjectCreating);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//this means that at the object creating event, the CLR is going to jump to my event handler (ods_ObjectCreating)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//after that, we only need to&amp;nbsp; bind the ODS to the GridView&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;gv.DataSource = ods;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gv.DataBind();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// AND THAT's ALL FOLKS !!!&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//this is the ObjectCreating event handler&lt;br /&gt;&amp;nbsp;&amp;nbsp;private void ods_ObjectCreating(object sender, ObjectDataSourceEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//calling a "parametered" constructor of my own TableAdapter and passing it to the ObjectInstance property&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;e.ObjectInstance = new MyTableAdapter(_dt, _vic);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//and that'all there's to it !!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;}&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;br /&gt;If you go very slowly through the code, you will find it very simple and straightforward. &lt;br /&gt;And best of all : you have the GridView display the pagerrow !!!&lt;/p&gt;
&lt;p&gt;Of course, the actual paging procedures are also to be written by you, but that's maybe for another post.&lt;/p&gt;
&lt;p&gt;Good luck !&lt;/p&gt;
&lt;p&gt;Erwin&lt;/p&gt;
&lt;p&gt;PS Important remark : if you have cute little datatable of only 10 records, then also the GridView PageSize should be set to 10 !! (Duh!)&lt;/p&gt;</description></item></channel></rss>