【问题标题】:Force a full PostBack from an <ItemTemplate> inside a <GridView> in an UpdatePanel从 UpdatePanel 中的 <GridView> 内的 <ItemTemplate> 强制执行完整的 PostBack
【发布时间】:2010-12-16 19:12:42
【问题描述】:

我发现这个解决方案可以强制从 UpdatePanel 中进行完整回发:

<Triggers>
    <asp:PostBackTrigger ControlID="controlID" />
 </Triggers>

但我的control 实际上是在嵌套在GridView 中的ItemTemplate 内。因此,当我的页面加载时,它找不到该控件。

如何从我的GridView 中强制从我的控件(asp:LinkButton)中进行完整回发?

【问题讨论】:

    标签: asp.net updatepanel postback linkbutton


    【解决方案1】:

    尝试在gridview的OnRowDatabound事件中获取控件,并使用scriptmanager注册回发控件。没试过,但我认为它应该可以工作......

    var control = e.Row.FindControl("YourControlID");
    if(control != null)
        ScriptManager.RegisterPostbackControl(control);
    

    【讨论】:

    • 我在 UpdatePanel 中有一个网格,我想在其中的链接上回发。我做了与上面相同的操作,但在第一次加载时链接正在工作,但没有。我可能会错过什么..?
    猜你喜欢
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 2017-05-13
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    相关资源
    最近更新 更多