<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>
Edit works perfectly fine which calls the following procedure
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
However; when I click on update, the following procedure is not called... any reason why? I changed the target control id to a label but it still does not call the save button event click below. Below never gets called...
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
Thank you for those who viewed my post, i finally found a way for this to work by using some JavaScript post back and added the following to my modal extender popup and it worked. hopefully this will help someone who is having the same issue
OkControlID="btnSave"
OnOkScript="__doPostBack('btnSave','')">