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

推荐订阅源

GbyAI
GbyAI
量子位
L
LINUX DO - 最新话题
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
博客园 - 聂微东
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
G
Google Developers Blog
MyScale Blog
MyScale Blog
罗磊的独立博客
Martin Fowler
Martin Fowler
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
H
Hacker News: Front Page
博客园 - Franky
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
AI
AI
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Recent Commits to openclaw:main
Recent Commits to openclaw:main
TaoSecurity Blog
TaoSecurity Blog
O
OpenAI News
Latest news
Latest news
T
Threat Research - Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
I
Intezer
Scott Helme
Scott Helme
MongoDB | Blog
MongoDB | Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Palo Alto Networks Blog
A
Arctic Wolf
AWS News Blog
AWS News Blog
S
Schneier on Security
Y
Y Combinator Blog
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More

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