2009-09-17 81 views
0

我试图使用GridView和UpdatePanels构建一种Accordion效果。我在将所有东西捆绑在一起时遇到问题:ASP.Net:在GridView中使用UpdatePanel

<asp:GridView ID="gridMain" 
    runat="server" 
    ... 
> 

<Columns> 

... 

<asp:TemplateField ShowHeader="False"> 
<ItemTemplate> 

<span>Id:<%# Eval("Id") %></span> 

<a href="/* javascript code to open the updatepanel??*/" title="Open"><img ..../></a> 

<asp:UpdatePanel runat="server"> 
<ContentTemplate> 
<asp:PlaceHolder runat="server" Visible="false"> 

<asp:Label Text="??"/> 

</asp:PlaceHolder> 
</ContentTemplate> 
</asp:UpdatePanel> 


</ItemTemplate> 
</asp:TemplateField> 

</Columns> 

</asp:GridView> 

如何使用javascript打开更新面板?

+0

我从来没有尝试数据控件有UpdatePanel的,甚至不知道这是否会工作。您可能想尝试JQuery的手风琴效果。 – 2009-09-17 15:00:53

回答

1

如果你真的想要去的UpdatePanel的方法,这里是如何使其工作:

  1. 指定UpdatePanel的ID和占位符控制
  2. 放一个LinkBut​​ton的UpdatePanel内和摆脱您目前有的链接
  3. 在GridView的ItemCommand中,使用FindControl获取对PlaceHolder控件的引用并使其可见。您也可以在这里使用Repeater而不是GridView。

现在我也说这可能不是最好的主意......但锤子,钉子,等...

0

对于手风琴的效果可能this website将有所帮助。 AJAX很好地处理它。

+0

我需要它在GridView中。该面板还必须在页面访问期间以独立方式加载并可更新。 – 2009-09-17 15:26:35

+0

@Niels使用JQuery Ajax函数也可以做到这一点。 – 2009-09-17 16:06:29