【问题标题】:RowIndex attribute of templated field inside update panel更新面板内模板化字段的 RowIndex 属性
【发布时间】: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


【解决方案1】:

VDWWD 评论的链接运行良好,将整个网格视图包装在更新面板中更有意义。

我一直在寻找这个:

RowIndex="<%# (DirectCast(Container, IDataItemContainer)).DisplayIndex %>" 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 2019-05-04
    • 1970-01-01
    • 2012-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多