你好,我希望这对某人来说很容易回答。首先,我试图ListView绑定到 aDataPager并放入一个 ASP.NETUpdatePanel来为我的数据库中的记录创建一个基于 AJAX 的寻呼机。我抓起一个UpdatePanel并放置:
SqlDataSourceListView- 在ItemTemplate其中包含一个ImageButton和几个其他 ASP.NET 控件DataPager
在ContentTemplate. DataPager将ID分配AsyncPostbackTrigger给UpdatePanel' 的触发字段中的效果非常好。
我还想在ImageButton Click活动中进行完整的回传。但是,由于ImageButton位于 内部ListView,因此UpdataPanel会导致部分回发。我尝试将 ImageButton 添加为UpdatePanel PostBackTrigger,但UpdatePanel需要控件 ID,并且不会接受,ImageButton因为它在ListView.
如何将内部元素的控件 ID 传递给它ItemTemplate并ListView成功地导致完整的回发?
这是我的代码:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:SqlDataSource ... ></asp:SqlDataSource>
<asp:ListView ID="ListViewForAlbums" runat="server" >
<ItemTemplate>
<div class="album">
<asp:ImageButton ID="albumPhoto" class="albumPhotosStyle" runat="server" ImageUrl="<%# Bind('albumPhotoPath') %>" AlternateText="<%# Bind('album_id') %>" ToolTip="<%# Bind('albumDetails') %>" onclick="albumPhotos_Click" />
<div class="albumInfoHolder">
...
</div>
</div> <!-- End Album -->
</ItemTemplate>
<EmptyDataTemplate>
<p>No Albums Yet. Check Back Soon!</p>
</EmptyDataTemplate>
</asp:ListView>
<asp:DataPager ID="DataPagerForAlbums" runat="server" PagedControlID="ListViewForAlbums" PageSize="3" >
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True" FirstPageText="«" ShowNextPageButton="False" ShowPreviousPageButton="false" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowLastPageButton="True" LastPageText="»" ShowPreviousPageButton="False" ShowNextPageButton="false" />
</Fields>
</asp:DataPager>
</p>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataPagerForAlbums" />
</Triggers>
</asp:UpdatePanel>