单击更新按钮后模态弹出窗口不调用事件

Modal Popup not calling event after clicking on the update button

  <asp:UpdatePanel ID="upGridview" runat="server" >
                <ContentTemplate>
<asp:GridView ID="GridView1" Height="150px" Width="100%" runat="server" BackColor="White" DataKeyNames="FacPacketID"
            BorderColor="#999999" BorderStyle="solid" BorderWidth="1px" CellPadding="3" AutoGenerateColumns="false"
            EnableModelValidation="True" GridLines="Vertical" AllowSorting="True" OnRowDataBound="GridView1_RowDataBound"
            OnSorting="gridView_Sorting" AutoGenerateEditButton="True" EditRowStyle-CssClass="rowStyleGreen" >

            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#a383c2" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small"
                ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle Font-Names="Arial" Font-Size="Small"  CssClass="rowStyle" backColor="Green"  ForeColor="Black" />
                <AlternatingRowStyle Font-Names="Arial" Font-Size="Small" BackColor="Aqua" CssClass="rowStyleAlt" ForeColor="Black" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:TemplateField ItemStyle-Width = "30px"  HeaderText = "EDit">
   <ItemTemplate>
       <asp:LinkButton ID="lnkEdit" runat="server" Text = "Edit Notes" CommandArgument="<%# Container.DataItemIndex %>" CommandName="Select"  OnClick="lnkEdit_Click"></asp:LinkButton>
   </ItemTemplate>
</asp:TemplateField>
        </Columns>
        </asp:GridView>

<asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup"  style = "display:none">
<asp:Label Font-Bold = "true" ID = "Label4" runat = "server" Text = "Submittal Notes update" ></asp:Label>
<br />
<table  align="center">
<tr>
<td>
<asp:TextBox ID="SubID" Width = "40px" MaxLength = "6" runat="server" Visible="false"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtnotes" runat="server" TextMode="MultiLine" style="width:400px; height:200px;"></asp:TextBox>    
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Update" Onclick ="Save" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"/>
</td>
</tr>
</table>
 </asp:Panel> 
                    
<%--<asp:Button ID="lnkFake" runat="server"></asp:Button>--%>
<asp:Label ID="lblclick" runat="server" />
<asp:ModalPopupExtender ID="popup" runat="server" DropShadow="false" 
    PopupControlID="pnlAddEdit" TargetControlID = "lblclick" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
 <asp:HiddenField ID="ID" runat="server" Value ="0" />                   
</ContentTemplate> 
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "GridView1" />
<asp:AsyncPostBackTrigger ControlID = "btnSave" />
</Triggers>  
        
        </asp:UpdatePanel>

调用以下过程的编辑工作非常好

  Protected Sub LnkEdit_Click(sender As Object, e As EventArgs)
        Using row As GridViewRow = DirectCast(DirectCast(sender, LinkButton).Parent.Parent, GridViewRow)
            Dim pk As String = GridView1.DataKeys(row.RowIndex).Values(0).ToString()
            Gridviewnotes = TryCast(GridView1.Rows(row.RowIndex).FindControl("lNotes"), Label)
            txtnotes.Text = Gridviewnotes.Text
            ID.Value = CInt(pk.ToString())
            popup.Show()
        End Using

    End Sub

但是;当我点击更新时,没有调用以下程序......有什么原因吗?我将目标控件 id 更改为标签,但它仍然没有调用下面的保存按钮事件单击。 下面永远不会被调用...

Protected Sub Save(sender As Object, e As EventArgs)
        txtnotes.Text = Replace(txtnotes.Text, "'", Chr(34))
        Dim connString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim myConnection As New SqlConnection(connString)
        Dim sql As String = ""
        Dim objCmd As New SqlCommand(sql, myConnection)
        myConnection.Open()
        objCmd.CommandText = "UPDATE Mytable SET ColumnName=@variable where Id=@ID "
        objCmd.CommandType = CommandType.Text
        objCmd.Parameters.AddWithValue("@Notes", @variable)
        objCmd.Parameters.AddWithValue("@FacpacketID", @ID))
        objCmd.ExecuteNonQuery()
        myConnection.Close()
        GridView1.DataBind()
    End Sub

感谢那些看过我的 post 的人,我终于找到了一种方法,通过使用一些 JavaScript post 返回并将以下内容添加到我的模态扩展程序弹出窗口它奏效了。希望这会帮助遇到同样问题的人

OkControlID="btnSave"  
         OnOkScript="__doPostBack('btnSave','')">