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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Engineering at Meta
Engineering at Meta
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
博客园_首页
云风的 BLOG
云风的 BLOG
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
博客园 - Franky
Cyberwarzone
Cyberwarzone
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cisco Blogs
T
Tailwind CSS Blog
Project Zero
Project Zero
博客园 - 叶小钗
S
SegmentFault 最新的问题
K
Kaspersky official blog
B
Blog
T
The Exploit Database - CXSecurity.com
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
G
Google Developers Blog
Security Latest
Security Latest
T
Tenable Blog
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
H
Help Net Security
T
Threat Research - Cisco Blogs
美团技术团队
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
F
Fortinet All Blogs
NISL@THU
NISL@THU
大猫的无限游戏
大猫的无限游戏
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
D
DataBreaches.Net

博客园 - zqf620

.Net PetShop 3.0中购物车总价计算的bug .NET PetShop 3.0 FAQ novalidate选项无效的问题 .NET方向高级开发人员面试时应该事先考虑的问题 (zt) UML中的图 从一组数中每次抽取出一个数,并规定了每个数出现的概率 从一个表中随即抽取100条记录 PL/SQL User's Guide and Reference, Release 2 (9.2) chm版 下载 Oracle中实现自动增长列 在开发过程中运用UML 输出到html页面的字符串的格式化 在DataGrid控件中编辑数据项 DataGrid控件的分页 DTD简介 W3C XML Schema (XSD) XML相关技术概览 将web窗体页文件(test.aspx)转换成用户控件文件(test.ascx) access作为后台数据库遇到的访问权限问题 HTML实体
在DataGrid控件中获取数据项中各列的数据内容
zqf620 · 2007-01-20 · via 博客园 - zqf620


在DataGrid控件中,一般只是在绑定列或模版列中进行数据显示。
在编写DataGrid控件(控件名为dg1)的事件的处理方法时,通常希望获取数据项某列的数据。
除了SelectedInexChanged事件外,其它事件的处理方法的参数e都是DataGridCommandEventArgs类的实例。通过e实例,可以获取引发事件的数据项中数据。

1.获取绑定列中的数据
1)处于非编辑状态、或者数据项处于编辑状态但该绑定列只读
  e.Item.Cells[列索引].Text

2)处于编辑状态
绑定列如果处于编辑状态,则会显示为TextBox控件形式
  ((TextBox)(e.Item.Cells[列索引].Controls[0])).Text

2.获取模版列中的数据
在模版列中可以放置一个或多个控件(右键"编辑模版"菜单),这些控件可以绑定数据源中的数据
要获取绑定到模版列中某控件上的数据,首先要知道该控件的id,然后用FindControl方法获得该控件的引用。
  ((控件类型)(e.Item.Cells[列索引].FindControl("控件id"))).控件的属性
eg:((CheckBox)(e.Item.Cells[3].FindControl("cbSex"))).Checked