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

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
Attack and Defense Labs
Attack and Defense Labs
Jina AI
Jina AI
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
H
Help Net Security
V
Visual Studio Blog
宝玉的分享
宝玉的分享
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
T
Tor Project blog
I
Intezer
美团技术团队
GbyAI
GbyAI
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
Y
Y Combinator Blog
博客园 - 司徒正美
T
Tenable Blog
O
OpenAI News
N
News and Events Feed by Topic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
Help Net Security
Help Net Security

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用dataTable 排序的解决方法 项目中遇到的一些小问题及解决方法 常用代码 一个com+消息队列的例子 部署Com+ 2004我的爱,2005我的期待 加密解密相关 生成略缩图 论坛在线人数统计代码 上礼拜六犯的愚蠢错误 正则表达式(1) 又一新的分页方法(转帖) 用户控件的使用(二) 用户控件的使用(一) DataList的使用(二)自定义分页的实现 DataList的使用(1) DataGrid的使用(2)自定义分页
DataGrid的使用(1)
生活即技术 · 2004-11-15 · via 博客园 - 生活即技术

Posted on 2004-11-15 16:18  生活即技术  阅读(427)  评论(0)    收藏  举报

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Data.WebForm1"%>
<HTML>
    
<body>
        
<form runat="server">
            
For our recordcount and pagecount
            
<asp:Label id="lblPageCount" runat="server" /><br>
            
<asp:DataGrid id="Data1" AllowPaging="True" OnPageIndexChanged="DataGrid_PageIndex" AutoGenerateColumns="False"
                runat="server" Width="536px">
                
<Columns>
                
<asp:BoundColumn DataField="id"></asp:BoundColumn>
                
<asp:HyperLinkColumn   DataNavigateUrlFormatString="aspx?id={0}" DataNavigateUrlField="uname" DataTextField="uname"  HeaderText="用户名" ></asp:HyperLinkColumn>
                
</Columns>
                
<PagerStyle  Width="100%"  NextPageText="下一页 " PrevPageText="上一页" PageButtonCount="5" Mode="NumericPages"></PagerStyle>
            
</asp:DataGrid>
            
        
</form>
    
</body>
</HTML>

后台代码

Public Class WebForm1
    
Inherits System.Web.UI.Page

#Region 
" Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    
End Sub

    
Protected WithEvents lblPageCount As System.Web.UI.WebControls.Label
    
Protected WithEvents Pubs As System.Web.UI.WebControls.DataGrid
    
Protected WithEvents ps As System.Web.UI.WebControls.DropDownList
    
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    
Protected WithEvents Data1 As System.Web.UI.WebControls.DataGrid

    
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
    '不要删除或移动它。
    Private designerPlaceholderDeclaration As System.Object

    
Private Sub Page_Init(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Init
        
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    
End Sub


#
End Region
    
Dim totalcount As Int32
    
Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
        
'在此处放置初始化页的用户代码
        Dim Myconnection As SqlClient.SqlConnection
        
Dim MyAdatper As SqlClient.SqlDataAdapter
        
Dim ds As New DataSet
        
Dim read As SqlClient.SqlDataReader
        
Dim connstr = "server=(local);uid=sa;pwd=;database=achem56;"
        Dim sql As String = "select top 100 id,uname  from user_login "
        Try
            Myconnection 
= New SqlClient.SqlConnection(connstr)
            Myconnection.Open()
            MyAdatper 
= New SqlClient.SqlDataAdapter(sql, Myconnection)
            MyAdatper.Fill(ds, 
"User_login")
            totalcount 
= ds.Tables("user_login").Rows.Count.ToString
            lblPageCount.Text 
= totalcount
            Data1.DataSource 
= ds.Tables("user_login")
            Data1.DataBind()
        
Catch ecc As Exception
            Response.
Write(ecc.Message)
            Response.
End()
        
Finally
        
End Try
        Response.
Write("连接成功")
    
End Sub

    
Sub DataGrid_PageIndex(ByVal sender As ObjectByVal e As DataGridPageChangedEventArgs)
        Data1.CurrentPageIndex 
= e.NewPageIndex
    
End Sub

End Class

刷新页面返回顶部