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

推荐订阅源

L
LangChain Blog
TaoSecurity Blog
TaoSecurity Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
SecWiki News
SecWiki News
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
V2EX - 技术
V2EX - 技术
Help Net Security
Help Net Security
Security Latest
Security Latest
T
Troy Hunt's Blog
腾讯CDC
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
T
Threatpost
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
Microsoft Security Blog
Microsoft Security Blog
V
Vulnerabilities – Threatpost
S
Secure Thoughts
M
MIT News - Artificial intelligence
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
G
Google Developers Blog
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
C
Cisco Blogs
罗磊的独立博客
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cybersecurity and Infrastructure Security Agency CISA
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Help Net Security
The Hacker News
The Hacker News
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
N
News and Events Feed by Topic
S
Securelist

博客园 - 一滴水

PHP基础学习(1)-Win2003下安装配置PHP 在右键菜单中添加 Dos cmd窗体,方便使用(意译) HTML转义字符表[zz] - 一滴水 - 博客园 SQLServer2000发生错误1069(由于登陆失败而无法启动服务)的解决方案[zz] - 一滴水 - 博客园 [转载]Javascript的IE和Firefox兼容性汇编 - 一滴水 - 博客园 Hibernate+mysql 乱码问题。。。 关于eclipse中cvs标记的[csdn] [Hibernate]在用hibernate3.0进行查询时,java.lang.NoClassDefFoundError: antlr/ANTLRException【问题记录】 js 文件的编码问题!! 【解决了】 我遇到的一些问题【解决了贴出来当积累了】 获得插入记录标识号的示例 读取Excel表格中的数据[copy] 如何得到服务器端数据库列表 并 备份和恢复数据库 [copy] 将 XML 文件做为数据源绑定到控件 单值数据绑定示例 网上整理 Web JS 通用 呵呵[还会陆续添加] 鼠标移到DataGrid的那行则更改那行的颜色!!! DataGrid中添加自动编号 关于使用docuemnt.write问题
如何在DataGrid控件中删除最后一页的最后一记录 !!!
一滴水 · 2005-03-30 · via 博客园 - 一滴水

Posted on 2005-03-30 09:06  一滴水  阅读(942)  评论(0)    收藏  举报

 1private void dgPagerDel_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 
 2  
 3   int empID = (int)dgPagerDel.DataKeys[e.Item.ItemIndex]; 
 4   string sqlCom = "delete Employees where EmployeeID="+empID.ToString(); 
 5   //定义数据连接对象,其中数据库连接字符串是在Web.Config文件中定义的 
 6   SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionSqlServer"].ToString()); 
 7   //定义命令对象 
 8   SqlCommand cmd = new SqlCommand(sqlCom,conn); 
 9   //打开数据连接 
10   conn.Open(); 
11   try 
12   
13    //执行SQL命令 
14    cmd.ExecuteNonQuery(); 
15    //取得当前页的索引 
16    lastEditedPage = dgPagerDel.CurrentPageIndex; 
17    //如果有多页并且当前页中的项数仅有一项 
18    if ((dgPagerDel.PageCount - dgPagerDel.CurrentPageIndex) == 1 && dgPagerDel.Items.Count == 1
19    
20     if (dgPagerDel.PageCount > 1
21     
22      lastEditedPage = lastEditedPage - 1
23     }
 
24     else 
25     
26      lastEditedPage = 0
27     }
 
28    }
 
29    dgPagerDel.CurrentPageIndex = lastEditedPage; 
30    DataGridDataBind(); 
31   }
 
32   catch(SqlException err) 
33   
34    //输出异常信息 
35    Response.Write(err.ToString()); 
36   }
 
37   finally 
38   
39    //关闭连接对象 
40    conn.Close(); 
41   }
 
42  }
 
43