Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 21st, 2007, 08:31 PM
Authorized User
Join Date: Jun 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to allow paging in datalist?

Do you know how to allow paging in datalist?

I get some source code on the internet, but they didnt mention how to connect to the database, the code just show to connect to the fix data( red color part). I need to connect to my database(enterprise) and table(Contents), so anyone can help me?

Example source code get from other website:

<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(byVal obj As Object, byVal e As EventArgs)
End Sub

Sub doPaging()
     Dim mockData As New HashTable()
  Dim IDx As Integer = 0
  Do Until IDx = 500
     mockData.Add(IDx.toString(), (IDx * 101).toString)
     IDx += 1

  Dim pagedData As New PagedDataSource()
  pagedData.DataSource = mockData
  pagedData.AllowPaging = True
  pagedData.PageSize = 5

  theDataList.DataSource = pagedData
End Sub

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <title>Paging Example 1</title>

     <asp:DataList id="theDataList" runat="server">

           Department: <%# DataBinder.Eval(Container.DataItem,
           "Key") %><br />
           Employee ID: <%# DataBinder.Eval(Container.DataItem,
           "Value") %></a><br />

Old January 21st, 2007, 10:08 PM
Authorized User
Join Date: Jun 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

just solve the problem..:)

the solution below here :

Dim args As DataSourceSelectArguments = New DataSourceSelectArguments()
Dim view As DataView = CType(SqlDataSource1.Select(args), DataView)
Dim table As DataTable = view.ToTable()
pagedData.DataSource = Table.DefaultView
pagedData.AllowPaging = True
pagedData.PageSize = 5

Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist with paging venkatu2005 ASP.NET 1.0 and 1.1 Professional 1 July 17th, 2008 01:10 AM
paging datalist shanwaj ASP.NET 2.0 Basics 1 March 25th, 2008 12:03 AM
Datalist Paging webnathan ASP.NET 1.0 and 1.1 Basics 3 November 19th, 2007 11:11 AM
Datalist Paging nedo_786 ASP.NET 2.0 Professional 9 September 20th, 2007 04:32 AM
Datalist Paging in C# caitydev ASP.NET 2.0 Basics 0 March 29th, 2006 06:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.