2013-07-25 102 views
1

我試圖搜索解決方案,但找不到任何解決方案。無處不在他們正在討論UpdatePanel中的Gridview。在我的情況下,我有一個GridView的EditItemTemplate中的UpdatePanel和該EditItemTemplate中的DropDownList導致SelectChange事件回發。我只想要那個單元格或最多gridview的那一行被部分渲染,但是整個頁面閃爍。GridView的EditItemTemplate中的UpdatePanel導致整個頁面刷新

我已經在那個頁面的其他地方使用了更新面板,但是在gridview之外,它工作正常。

GridView模板中不支持UpdatePanel嗎?

謝謝!

+0

如果將UpdatePanel移到外面幷包裝整個GridView,會發生什麼? –

+0

我想它會工作,但我不想刷新整個gridview如果只有一行正在更新。如果對原始問題沒有找到任何解決方案,我可能必須最終這樣做。 – Aamir

回答

3

您需要在UpdatePanel 的<Triggers>元素內指定AsyncPostBackTrigger。我嘗試過,並且工作。

<asp:UpdatePanel ID="upSetSession" runat="server"> 
      <ContentTemplate> 
       <asp:DropDownList ID="ddlMyList" runat="server" 
        onselectedindexchanged="ddlMyList_SelectedIndexChanged" 
        AutoPostBack="true"> 
        <asp:ListItem>One</asp:ListItem> 
        <asp:ListItem>Two</asp:ListItem> 
        <asp:ListItem>Three</asp:ListItem> 
       </asp:DropDownList> 
      </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="ddlMyList" 
        EventName="SelectedIndexChanged" /> 
      </Triggers> 
     </asp:UpdatePanel> 
+1

非常感謝!這解決了問題。由於DropdownList在UpdatePanel中,我從來沒有想到它也應該被設置爲truggers。我認爲觸發器應該在UpdatePanel之外。任何方式都可以完成工作。這是導致錯誤,並不認識我提供的EventName,即使它是正確的。我不得不刪除它,它的工作正常。沒有更多的完整頁面閃爍。 – Aamir

相關問題