如何从父控件获取Container.DataItem?
假设我创建一个 ASP.net 中继器。进一步假设我将 ASP.net GridView 放入 ASP.net 中继器的 ItemTemplate 中。
假设它看起来像这样:
<asp:Repeater runat='server' id='myRepeater'>
<ItemTemplate>
<%# "This Repeater DataSource is " + Container.DataItem.ToString() %>
<asp:GridView runat='server' id='repeaterGridView'>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<% // I would like to refer to the Repeater Data Source here, but I only know
// how to refer to the GridView Data Source here.
<ItemTemplate>
</asp:templateField>
</Columns>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
我想引用 GridView 的 TemplateField 内的 Repeater 数据源。我该怎么做?
Suppose that I create an ASP.net repeater. Suppose further that I put an ASP.net GridView in the ASP.net repeater's ItemTemplate.
Suppose that it looks like this:
<asp:Repeater runat='server' id='myRepeater'>
<ItemTemplate>
<%# "This Repeater DataSource is " + Container.DataItem.ToString() %>
<asp:GridView runat='server' id='repeaterGridView'>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<% // I would like to refer to the Repeater Data Source here, but I only know
// how to refer to the GridView Data Source here.
<ItemTemplate>
</asp:templateField>
</Columns>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
I would like to refer to the Repeater DataSource inside a TemplateField for the GridView. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Container 引用了 TemplateField,因此请尝试调用
Container refers to the TemplateField, so try calling