Sign in | Join
Last post 10-18-2006 2:04 AM by rexlin. 2 replies.
Sort Posts: Oldest to newest Newest to oldest
Hi,
In my asp.net page i am using datalist and i want to paging but i am not find the any propertie onf paging in datalist i am using .net 1.1.
is 1.1 not provide the paging in datalist
if yes then how??
regard
1.1 does not provide the paging in datalist. the DataGrid control—natively supports paging .
But you can create a Pager Control for DataList . See Creating a Pager Control for ASP.NET .
Hi,khushak:
You can use PagedDataSource. Here is the sample:
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 2
3 Dim sqlconn As New SqlConnection(ConfigurationSettings.AppSettings.Get("sqlserver")) 4 sqlconn.Open() 5 Dim sqlda As New SqlDataAdapter("select * from vote_items", sqlconn) 6 Dim dt As New DataTable 7 sqlda.Fill(dt) 8 sqlda.Dispose() 910 11 Dim pds As New PagedDataSource12
13
14 pds.DataSource = dt.DefaultView15 '==================================================16 pds.AllowPaging = True17 pds.PageSize = 3 1819
20 Dim currentpage As Integer21 If Request.QueryString.Get("page") <> Nothing Then22 currentpage = Convert.ToInt32(Request.QueryString("Page"))23 Else24 currentpage = 125 End If26
27 pds.CurrentPageIndex = currentpage - 12829 Label1.Text = "共有记录" & pds.DataSourceCount & "条,分" & pds.PageCount & "页显示,每页显示" & _30 pds.PageSize & "条,当前为第" & currentpage & "页:"3132 33 If Not pds.IsFirstPage Then34 lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToInt32(currentpage - 1)35 lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=1"36 End If3738 If Not pds.IsLastPage Then39 lnkNext.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToInt32(currentpage + 1)40 lnkLast.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & pds.PageCount41 End If4243 '
44 rp.DataSource = pds45 rp.DataBind()