Custom Paging From ADO dataset

Rabbitdildosr

New Member
I found this article in the msdn:<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassallowcusto mpagingtopic.asp<BR><BR>It works great.<BR><BR>I tried modifying it to pull a dataset intead of the collection object. The results show up fine.<BR><BR>You can click the page buttons and they move position, but i cannot get the display to change in sync with the page buttons.<BR><BR>In otherwords, the datagrid always shows the first set of results no matter what i click on.<BR><BR>Does anyone know how to do custom paging from a data set out of an Access database???<BR><BR>Any help would be appricated!!!!!!<BR><BR>Below is the code that i modifed:<BR><BR><%@ Page SmartNavigation="true" %> <BR><!--#Include File = "DBinventory.aspx"--><BR><% @Import Namespace="System.Data" %><BR><% @Import Namespace="System.Data.OleDb" %><BR><html><BR><BR><script language="VB" runat="server"><BR><BR> Dim start_index As Integer<BR><BR> Function CreateDataSource() As ICollection<BR> Dim DS As DataSet<BR> Dim MyCommand As OleDbDataAdapter<BR> MyCommand = New OleDbDataAdapter("SELECT * FROM tblOrdersProcessed " , MyConnection)<BR> <BR> DS = new DataSet()<BR> MyCommand.Fill(DS, "tblOrdersProcessed")<BR> Dim Source As DataView = DS.Tables("tblOrdersProcessed").DefaultView<BR> <BR> Return Source<BR> End Function 'CreateDataSource<BR> <BR> <BR> <BR> Sub Page_Load(sender As Object, e As EventArgs)<BR> <BR> If CheckBox1.Checked Then<BR> ItemsGrid.PagerStyle.Mode = PagerMode.NumericPages<BR> Else<BR> ItemsGrid.PagerStyle.Mode = PagerMode.NextPrev<BR> End If <BR> If Not IsPostBack Then<BR> start_index = 0<BR> ItemsGrid.VirtualItemCount = 80<BR> End If<BR> <BR> BindGrid()<BR> End Sub 'Page_Load<BR> <BR><BR> Sub Grid_Change(sender As Object, e As DataGridPageChangedEventArgs)<BR> <BR> ItemsGrid.CurrentPageIndex = e.NewPageIndex<BR> start_index = ItemsGrid.CurrentPageIndex * ItemsGrid.PageSize<BR> BindGrid()<BR> End Sub 'Grid_Change<BR> <BR><BR> Sub BindGrid()<BR> <BR> ItemsGrid.DataSource = CreateDataSource()<BR> ItemsGrid.DataBind()<BR> End Sub 'BindGrid <BR></script><BR><BR><body><BR><BR> <form runat=server><BR><BR> <h3>DataGrid Custom Paging Example</h3><BR><BR> <asp:DataGrid id="ItemsGrid" runat="server"<BR> BorderColor="black"<BR> BorderWidth="1"<BR> CellPadding="3"<BR> AllowPaging="true"<BR> AllowCustomPaging="true"<BR> PageSize="5"<BR> AutoGenerateColumns="false"<BR> OnPageIndexChanged="Grid_Change"><BR><BR> <PagerStyle NextPageText="Forward"<BR> PrevPageText="Back"<BR> Position="Bottom"<BR> PageButtonCount="5"<BR> BackColor="#00aaaa"><BR> </PagerStyle><BR><BR> <AlternatingItemStyle BackColor="yellow"><BR> </AlternatingItemStyle><BR><BR> <HeaderStyle BackColor="#00aaaa"><BR> </HeaderStyle><BR><BR> <Columns><BR> <BR> <asp:BoundColumn HeaderText="Number" <BR> DataField="ID"/><BR> <BR> <asp:BoundColumn HeaderText="Number" <BR> DataField="OrderID"/> <BR><BR> <asp:BoundColumn<BR> HeaderText="Item" <BR> DataField="VendorID"/><BR><BR> <asp:BoundColumn <BR> HeaderText="Price" <BR> DataField="VendorCost" <BR> DataFormatString="{0:c}"><BR><BR> <ItemStyle HorizontalAlign="right"><BR> </ItemStyle><BR> <BR> </asp:BoundColumn><BR><BR> </Columns><BR> <BR> </asp:DataGrid><BR><BR> <BR><BR><BR> <asp:CheckBox id="CheckBox1" <BR> Text = "Show page navigation"<BR> AutoPostBack="true"<BR> runat="server"/><BR><BR> </form><BR><BR></body><BR></html><BR> <BR>
 
Back
Top