你好,我希望这对某人来说很容易回答。首先,我试图ListView
绑定到 aDataPager
并放入一个 ASP.NETUpdatePanel
来为我的数据库中的记录创建一个基于 AJAX 的寻呼机。我抓起一个UpdatePanel
并放置:
SqlDataSource
ListView
- 在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>