asp.net - Getting Eval value from parent Data control
问题描述
I have a DetailsView
with a TemplateField
that contains a GridView
.
When using Eval
inside the GridView
cells, I only get access to the data source of the GridView
.
How can I access the data of the parent, i.e. the DetailsView
?
Thank You
<asp:DetailsView ID="det1" DataSourceID="source1">
<asp:TemplateField>
<ItemTempalte>
<asp:GridView ID="grid1" DataSourceID="source2">
<Columns>
<asp:TemplateField>
<ItemTempalte>
//this is where I need a column from source1 while Eval only gives me source2
<asp:Label Text='<%# Eval("column from source1") %>'/>
</ItemTempalte>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ItemTempalte>
</asp:TemplateField>
</asp:DetailsView>
解决方案
跳过怎么样Eval()
。尝试这样的事情
<asp:Label Text='<%# CType(source1.DataItem, System.Data.DataRowView)("column from source1") %>' />
您可能需要检查对象是否为Source1
,以查看其DataItem
是否为DataRowView
或其他类型。我在你定义的地方看不到你的代码source1
,所以我只能提供我最好的猜测。
推荐阅读
- iccube-reporting - 带维度标题的 IcCube 表
- netlogo - 连接时,乌龟的 NetLogo 链断开
- python - 如何知道python anaconda分布中numpy使用的MKL版本?
- c++ - 需要有关使用 Visual Studio 17 将 QT 桌面应用程序打包成 AppX 格式的指导
- node.js - 我怎样才能从一个嘲笑的类中模拟一个方法?
- android - 如何检查多边形的两条线中的任何一条是否相交(交叉)
- javascript - 包含导航栏子菜单代码的外部 Java 脚本文件不起作用
- iis - 在 IIS 中设置服务器变量
- c# - 从 CSV 字段中删除不必要的引号
- java - Firebase 实时数据库值检索