功能:
1.每页设置显示9页,超过9页,点5页后的+1页显示(可以随便修改)
2.CSS样式自己可以设置
3.无任何咋代码产生,利于搜索引擎优化
4.至于性能怎么样大家可以试下
1.每页设置显示9页,超过9页,点5页后的+1页显示(可以随便修改)
2.CSS样式自己可以设置
3.无任何咋代码产生,利于搜索引擎优化
4.至于性能怎么样大家可以试下
- Dim objPDS As PagedDataSource
- '分页程序
- objPDS = New PagedDataSource()
- objPDS.DataSource = dtTable.DefaultView
- '绑定数据源
- objPDS.AllowPaging = True
- objPDS.PageSize = 10
- '分页数目
- Dim curPage As Integer
- Dim cshi As Integer
- Dim jshi As Integer
- Dim zyes As Integer = Int32.Parse(objPDS.PageCount.ToString())
- Me.tjixx.Text = "总共 <font color=red>" & dtTable.Rows.Count & " </font>条信息"
- Me.tjixx.Text += "|共 <font color=red>" & zyes & " </font>页"
- If Request.QueryString("Page") IsNot Nothing Then
- If Int32.Parse(Request.QueryString("Page")) > zyes Then
- curPage = zyes
- Else
- curPage = Int32.Parse(Request.QueryString("Page"))
- End If
- Else
- curPage = 1
- End If
- If zyes <= 9 Then
- cshi = 1
- jshi = zyes
- Else
- If curPage <= 5 Then
- cshi = 1
- jshi = 9
- Else
- cshi = curPage - 4
- Dim jshils As Integer = curPage + 4
- If jshils > zyes Then
- jshi = zyes
- Else
- jshi = curPage + 4
- End If
- End If
- End If
- objPDS.CurrentPageIndex = curPage - 1
- Dim m_strPageInfo As New StringBuilder()
- For i As Integer = cshi To jshi
- If i = Int32.Parse(curPage.ToString()) Then
- m_strPageInfo.Append(" <span class=""dqye""> <strong>" & i & " </strong> </span> ")
- Else
- m_strPageInfo.Append(((" <span class=""qtye""> <strong> <a href=""newslist_ej" & Request.QueryString("wzcat") & "_Page") + i & ".html"">") + i & " </a> </strong> </span> ")
- End If
- Next
- Me.yemsl.Text = m_strPageInfo.ToString()
- If Not objPDS.IsFirstPage Then
- linkPre.NavigateUrl = ("newslist_ej" & Request.QueryString("wzcat") & "_Page") + Convert.ToString(curPage - 1)
- linkPre.NavigateUrl += ".html"
- End If
- If Not objPDS.IsLastPage Then
- linkNext.NavigateUrl = ("newslist_ej" & Request.QueryString("wzcat") & "_Page") + Convert.ToString(curPage + 1)
- linkNext.NavigateUrl += ".html"
- End If
- linkFirstPage.NavigateUrl = "newslist_ej" & Request.QueryString("wzcat") & "_Page1"
- linkFirstPage.NavigateUrl += ".html"
- linkEndPage.NavigateUrl = ("newslist_ej" & Request.QueryString("wzcat") & "_Page") + objPDS.PageCount.ToString()
- linkEndPage.NavigateUrl += ".html"
- Me.DataList4.DataSource = objPDS
- '绑定分页的数据
- Me.DataList4.DataBind()