gridview内部更新面板无法正常工作

时间:2017-11-22 04:21:51

标签: asp.net ajax gridview updatepanel

我在GridView中有一些图像按钮,当我点击这些图像按钮时,整个页面都会刷新。我只想点击那个图像按钮而不重新加载整个页面时触发该图像按钮事件。我也使用了updatepanel。 我在两天后面临这个问题,现在我需要帮助,我无法做到这一点。

这是我的.aspx

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" ></asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                 <Triggers>
                     <asp:AsyncPostBackTrigger ControlID="updatebutton" EventName="Click" />
                 </Triggers>
                 <ContentTemplate>
                     <asp:ImageButton ID="updatebutton" runat="server" Visible="false" OnPreRender="ImageButton_PreRender" OnClick="ImageButton_Click" />
                     <asp:GridView ID="gvSeatLayout" runat="server" AutoGenerateColumns="False" Width="755px" AllowPaging="True" 
                         OnRowDataBound="gvSeatLayout_RowDataBound" OnRowCreated="gvSeatLayout_RowCreated"
                         PageSize="25" ShowHeader="False" CellSpacing="0" CellPadding="5" BorderStyle="None"  >
                         <RowStyle CssClass="gvspace" />
                         <Columns>
                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <table>
                                         <tr><td>
                                             <asp:LinkButton ID="LinkButton1" Enabled="false" Font-Bold="true" ForeColor="White" CommandName="lbtnRowId" CommandArgument='<%# Eval("RowId") %>'  Text='<%# RowName(Eval("RowName").ToString()) %>' runat="server"></asp:LinkButton>
                                         </td>
                                         </tr>
                                         <td></td></table>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>
                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton1" CssClass="ss" OnClick="ImageButton_Click" CommandArgument='<%# Eval("L1") %>' CommandName="ib1"  runat="server" ImageUrl='<%# MyUrl(Eval("L1").ToString(),Eval("RowId").ToString()) %>' />
                                     <asp:PopupControlExtender ID="PopupControlExtender1" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton1" dynamiccontextkey='<%# Eval("L1") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>

                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton3" runat="server"  CssClass="ss" OnClick="ImageButton_Click"    CommandArgument='<%# Eval("L3") %>' CommandName="ib3" ImageUrl='<%# MyUrl(Eval("L3").ToString(),Eval("RowId").ToString()) %>'/>
                                     <asp:PopupControlExtender ID="PopupControlExtender2" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton3" dynamiccontextkey='<%# Eval("L3") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>
                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton4" runat="server"  CssClass="ss" OnClick="ImageButton_Click"    CommandArgument='<%# Eval("L4") %>' CommandName="ib4" ImageUrl='<%# MyUrl(Eval("L4").ToString(),Eval("RowId").ToString()) %>'/>
                                     <asp:PopupControlExtender ID="PopupControlExtender3" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton4" dynamiccontextkey='<%# Eval("L4") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>


                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton8" runat="server" CssClass="ss"  OnClick="ImageButton_Click" CommandArgument='<%# Eval("U1") %>' CommandName="ib8"  ImageUrl='<%# MyUrl(Eval("U1").ToString(),Eval("RowId").ToString()) %>'/>
                                     <asp:PopupControlExtender ID="PopupControlExtender4" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton8" dynamiccontextkey='<%# Eval("U1") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>

                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton10" runat="server" CssClass="ss" OnClick="ImageButton_Click" CommandArgument='<%# Eval("U3") %>' CommandName="ib10"  ImageUrl='<%# MyUrl(Eval("U3").ToString(),Eval("RowId").ToString()) %>'/>
                                     <asp:PopupControlExtender ID="PopupControlExtender5" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton10" dynamiccontextkey='<%# Eval("U3") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>
                             <asp:TemplateField>
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton11" runat="server" CssClass="ss" OnClick="ImageButton_Click" CommandArgument='<%# Eval("U4") %>' CommandName="ib10" 
                                         ImageUrl='<%# MyUrl(Eval("U4").ToString(),Eval("RowId").ToString()) %>'/>
                                     <asp:PopupControlExtender ID="PopupControlExtender6" runat="server" popupcontrolid="Panel1"
                                         targetcontrolid="ImageButton11" dynamiccontextkey='<%# Eval("U4") %>' dynamiccontrolid="Panel1" 
                                         dynamicservicemethod="GetDynamicContent" position="Bottom">
                                     </asp:PopupControlExtender>
                                 </ItemTemplate>
                                 <ItemStyle BorderStyle="None" />
                             </asp:TemplateField>


                         </Columns>
                         <FooterStyle BorderStyle="None" />
                         <SelectedRowStyle BorderStyle="None" />
                         <EditRowStyle BorderStyle="None" />
                         <AlternatingRowStyle BorderStyle="None" />
                     </asp:GridView>
                 </ContentTemplate>
             </asp:UpdatePanel>

1 个答案:

答案 0 :(得分:0)

尝试将更新模式更改为&#34;始终&#34;。目前,Async方法与&#34; updatebutton&#34;。

绑定在一起