updatepanel内的按钮无法正常工作

时间:2009-11-15 07:58:39

标签: .net asp.net gridview asp.net-ajax updatepanel

我正在Button2上的数据库中检索下载网址,但是当我将GridView放入UpdatePanel时,它会出现以下错误:

  

Microsoft JScript运行时错误:Sys.WebForms.PageRequestManagerParserErrorException:

代码:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                  DataSourceID="SqlDataSource1" ShowHeaderWhenEmpty="True" 
                  EmptyDataText="No Uploads are found" ShowEmptyTable="True"
                  ShowFooterWhenEmpty="False" Style="margin-top: 20px" 
                  OnSelectedIndexChanged="GridView2_SelectedIndexChanged"
                  OnRowDataBound="GridView2_RowDataBound">
      <asp:TemplateField ShowHeader="False" HeaderText="Receive">
        <ItemTemplate> 
          <asp:Button ID="Button2" runat="server" CausesValidation="false" CommandName="select" Text="Receive" /> 
        </ItemTemplate>
      </asp:TemplateField>
    </asp:GridView>
  </ContentTemplate>
</asp:UpdatePanel>

1 个答案:

答案 0 :(得分:1)

尝试在UpdatePanel中添加触发器:

</ContentTemplate> 
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />        
</Triggers>