I need some help with the code for a datalist. I want to use paging for this datalist.
I got the following error message:
Compiler Error Message: BC30456: 'CurrentPageIndex' is not a member of 'System.Web.UI.WebControls.DataList'.
Source Error:
|
Line 25:
Line 26: 'Get new paging index
Line 27: dtlGBook.CurrentPageIndex = objArgs.NewPageIndex
|
I know what this means. CurrentPageIndex is not a member of DataList. It's actually a member of DataGrid. What should I use instead for DataList?
Let me give the significiant parts of my code:
Sub dtlGBook_PageChanger(objSender As Object, _
& ;nbs p; &a mp;n bsp; objArgs As DataGridPageChangedEventArgs )
'Get new paging index
dtlGBook.CurrentPageIndex = objArgs.NewPageIndex
Call BindDataList()
End Sub
'---------------------------------------------
' name: BindDataList()
'---------------------------------------------
Sub BindDataList()
Dim strConnect As String
Dim objConnect As New OleDbConnection()
Dim objCommand As New OleDbCommand()
Dim strSQL as String
Dim dtaGBook As New OleDbDataAdapter()
Dim dtsGBook As New DataSet()
Dim databaseName as String
Dim path as String
databaseName = ""
'Create Connection object
objConnect.ConnectionString = strConnect
objConnect.Open()
'Build SQL string
strSQL = "My SQL Statement"
'Set the Command Object properties
objCommand.Connection = objConnect
objCommand.CommandType = CommandType.Text
objCommand.CommandText = strSQL
'Create a new DataAdapter object
dtaGBook.SelectCommand = objCommand
'Get the data from the database and
'put it into a DataTable object named dttGBook in the DataSet object
dtaGBook.Fill(dtsGBook, "dttGBook")
'Set the DataSource property of the DataList
dtlGBook.DataSource = dtsGBook
'Bind all the controls on the page
dtlGBook.DataBind()
End Sub
Small parts of my code after <form runat="server"> :
<asp:datalist id="dtlGBook" runat="server"
width=600
AllowPaging="True"
OnPageIndexChanged="dtlGBook_PageChanger"
PagerStyle-Mode="NumericPages"
Pagesize="5"
enableviewstate=false>
Edited by Misty - 26 January 2005 at 1:30am