惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
T
Troy Hunt's Blog
P
Proofpoint News Feed
H
Help Net Security
博客园 - 叶小钗
N
Netflix TechBlog - Medium
F
Full Disclosure
Vercel News
Vercel News
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
V
V2EX
Latest news
Latest news
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
M
MIT News - Artificial intelligence
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Exploit Database - CXSecurity.com
Microsoft Security Blog
Microsoft Security Blog
S
Secure Thoughts
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Spread Privacy
Spread Privacy
S
Securelist
Forbes - Security
Forbes - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
Vulnerabilities – Threatpost
MyScale Blog
MyScale Blog
G
Google Developers Blog
L
Lohrmann on Cybersecurity
博客园 - Franky
T
Tor Project blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Visual Studio Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
Y
Y Combinator Blog

博客园 - symjie

每天学一点AS3.0(五)---声音的控制(5) 每天学一点AS3.0(四)---声音的控制(4) 每天学一点AS3.0(三)---声音的控制(3) 每天学一点AS3.0(二)---声音的控制(2) 每天学一点AS3.0(一)---声音的控制 Jquery json的超强组合 - symjie - 博客园 javascript分页程序 - symjie - 博客园 初试jquery制作一个简单的loading delegate——委派 - symjie - 博客园 sql 分页 Ajax.net和GridView交互 Ajax.net实现loading登陆的效果 - symjie - 博客园 Ajax.net+模态窗口的登陆简单例子 用下拉列表控制gridview的分页 DataView数据组件 (转) c#冒泡程序 Atlas学习笔记 getElementByTagsName和相关函数的学习 基于Ajax.net的验证
GridView自定义分页(vb) - symjie - 博客园
symjie · 2006-11-26 · via 博客园 - symjie

在用GridView里自带的分功能的时候,出现在一个有点奇怪的问题,点下面的页码,会执行上面按钮扭执行的动作,所以就用了一个自定义分页的功能。现将功能描述如下:

aspx页代码:

aspx.vb代码:

Imports System.Data
Imports System.Data.SqlClient

Partial Class more_newproducts
    
Inherits System.Web.UI.Page

    
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load
        GridViewBind()
    
End Sub


    
Protected Sub PagerButtonClick(ByVal sender As ObjectByVal e As EventArgs)

        
Dim arg As String = (CType(sender, LinkButton)).CommandArgument.ToString()

        
Select Case arg

            
Case "prev"
                
If (GridView1.PageIndex > 0Then

                    GridView1.PageIndex 
-= 1
                
End If

            
Case "next"
                
If (GridView1.PageIndex < (GridView1.PageCount - 1)) Then

                    GridView1.PageIndex 
+= 1
                
End If

            
Case "last"
                GridView1.PageIndex 
= (GridView1.PageCount - 1)

            
Case "first"
                GridView1.PageIndex 
= 0

        
End Select
        GridViewBind()
    
End Sub

    
Private Sub GridViewBind()
        
Dim conn As New SqlConnection
        conn.ConnectionString 
= Application("conn")
        conn.Open()
        
Dim sql As String = "SELECT [productid], [productname], [pifajia], [price], [s_imgurl], [pinpai], [changdi] FROM [products] ORDER BY [fabushijian] DESC"
        
Dim dt As DataSet = New DataSet
        
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, conn)
        da.Fill(dt)
        GridView1.DataSource 
= dt.Tables(0).DefaultView
        GridView1.DataBind()
        LblCurrentIndex.Text 
= "第<font color='red'>" + (GridView1.PageIndex + 1).ToString() + "</font> 页"
        LblPageCount.Text 
= "共<font color='red'> " + GridView1.PageCount.ToString() + "</font> 页"
        LblRecordCount.Text 
= "总共<font color='red'> " + dt.Tables(0).Rows.Count.ToString() + "</font> 条"
        
If (dt.Tables(0).Rows.Count = 0Then
            btnFirst.Visible 
= False
            btnPrev.Visible 
= False
            btnNext.Visible 
= False
            btnLast.Visible 
= False
            LblCurrentIndex.Visible 
= False
            LblPageCount.Visible 
= False
            LblRecordCount.Visible 
= False
            LblNoRecord.Visible 
= True
        
ElseIf (GridView1.PageCount = 1Then
            btnFirst.Visible 
= False
            btnPrev.Visible 
= False
            btnNext.Visible 
= False
            btnLast.Visible 
= False
        
End If
    
End Sub


End Class