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

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - JonsonXP

IT大师路线图,你还差多远? 团队决策的三大法宝 多核,个人计算并行时代才刚刚开始(Parallel Computing) 从主频之争到多核之争,摩尔定律还能走多远? 太阳能手机充电器毕设,51代码,附正文 JonsonXP is Back 推荐几个.NET开源图表组件 Asp.net未处理异常的2种解决方式 DATAGRID实现数据筛选分类汇总的数据显示 ASP.NET控件 C#中获取文件或目录的Icon 使用Visual C#实现断点续传 为服务器控件添加javascript客户端事件 在ASP.NET中动态创建柱状图和饼图 总结:Connection大全 Page Events: Order and PostBack DataGrid 自定义分页 在用户控件中撰写JS时控件的客户端ID问题 正则表达式语法
用DataBinder绑定索引器
JonsonXP · 2005-02-07 · via 博客园 - JonsonXP

nhibernate的Session.Find方法返回的可能是一个对象数组的集合, 例如Find("Select customer.Id, customer.Name From Customer customer") , 它返回的是由object[2]组成的ArrayList. 不知怎么绑定到DataGrid好, 后来发现DataBinder.Eval可以用"[xxx]"的表达式去访问索引器. 所以
<%#DataBinder.Eval(Container.DataItem, "[0]")%>
<%#DataBinder.Eval(Container.DataItem, "[1]")%>
就分别可以得到Customer的Id和Name了

常见绑定格式,不过他们的性能有区别。
<%# DataBinder.Eval(Container.DataItem, "[n]") %>

<%# DataBinder.Eval(Container.DataItem, "ColumnName") %>
<%# DataBinder.Eval(Container.DataItem, "ColumnName", null) %>
<%# DataBinder.Eval(Container, "DataItem.ColumnName", null) %>

<%# ((DataRowView)Container.DataItem)["ColumnName"] %>
<%# ((DataRowView)Container.DataItem).Row["ColumnName"] %>
<%# ((DataRowView)Container.DataItem)["adtitle"] %>
<%# ((DataRowView)Container.DataItem)[n] %>
<%# ((DbDataRecord)Container.DataItem)[0] %>
<%# (((自定义类型)Container.DataItem)).属性.ToString() %>(如果属性为字符串类型就不用ToString()了)
上面这三个性能最好。