【发布时间】:2017-12-14 13:56:37
【问题描述】:
我希望我的模板化按钮周围有一个更新面板,但它弄乱了控件的 rowindex 属性。我试图获取容器的父级,但它说 displayindex 不是属性
<ItemTemplate>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="IBRemove" EventName="click" />
</Triggers>
<ContentTemplate>
<asp:ImageButton ID="IBRemove" runat="server" RowIndex="<%# Contanier.Parent.Displayindex %>" OnClick="IBRemove_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
【问题讨论】:
-
不要在
ItemTemplate中使用UpdatePanel。将整个 GridView 包装在单个 UpdatePanel 中。 -
这是我最初的想法,但触发器控件 id 找不到模板化控件。所以我决定把它放在项目模板中,这样触发器就可以访问按钮
-
查看我的回答here。这显示了如何在代码后面分配触发器。
标签: asp.net vb.net updatepanel aspxgridview