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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LINUX DO - 热门话题
Blog — PlanetScale
Blog — PlanetScale
博客园 - Franky
J
Java Code Geeks
腾讯CDC
博客园 - 聂微东
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Last Week in AI
Last Week in AI
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Schneier on Security
C
CERT Recently Published Vulnerability Notes
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Securelist
AWS News Blog
AWS News Blog
GbyAI
GbyAI
L
LINUX DO - 最新话题
大猫的无限游戏
大猫的无限游戏
Forbes - Security
Forbes - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
Y
Y Combinator Blog
W
WeLiveSecurity
T
Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Proofpoint News Feed
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
V
V2EX
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
D
Docker
The Hacker News
The Hacker News
A
About on SuperTechFans
Security Latest
Security Latest
NISL@THU
NISL@THU
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
博客园_首页
H
Hacker News: Front Page

博客园 - 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