我有一个ListView
并且在其中我有一个CheckBox
AutoPostBack
设置为true
,我也有一个可折叠的面板保持在同一个与此ListView
相邻的CheckBox
。
对于Silent Post,整个内容都保留在UpdatePanel
内。现在我的问题是,当我点击UpdatePanel
整个页面正在刷新时,它被保留在CheckBox
内。我需要使用Silent PostBack来完成它。我怎样才能实现这个目标?
<asp:ListView ID="ListViewGroups" runat="server"
onitemdatabound="ListView1_ItemDataBound">
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Panel ID="PanelContainer" runat="server" Width="400px">
<asp:Panel ID="PanelHeaderList" runat="server" Width="20px">
<div style="float:left;" >
<asp:ImageButton ID="Image1" runat="server"
ImageUrl="~/expand_blue.jpg"
AlternateText="(Show Details...)"/>
</div>
</asp:Panel>
<div style="float:left;" >
<asp:CheckBox ID="CheckBox1" runat="server"
AutoPostBack="true" />
<asp:Label ID="Grp_NameLabel" runat="server"
Text='<%# Eval("Grp_Name") %>' />
<asp:HiddenField ID="hfGrpID" runat="server"
Value='<%#Eval("Grp_ID") %>' />
</div>
<br />
<p>
<asp:Panel ID="PanelGroupsItem" runat="server"
Width="100px" >
<asp:Panel ID="MyGroups" runat="server"
ScrollBars="Vertical"
Height="200px"
Width="300px"
Visible='<%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %>'>
//Another Normal gridView here just showing some data
</asp:Panel>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
runat="server"
Collapsed="true"
TargetControlID="PanelGroupsItem"
CollapseControlID="PanelHeaderList"
ExpandControlID="PanelHeaderList"
ImageControlID="Image1"
ExpandedImage="~/collapse_blue.jpg"
CollapsedImage="~/expand_blue.jpg"
SuppressPostBack="true"
>
</asp:CollapsiblePanelExtender>
</asp:Panel>
</p>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server"
border="0" style="">
<tr runat="server" style="">
<th runat="server">
Groups</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
请帮我解决这个问题
答案 0 :(得分:2)
我在这里找到了类似问题的解决方案:Checkboxlist inside UpdatePanel triggers full postback when an item is checked。
您需要将checkBox的ClientID模式设置为AutoID。