I have two buttons inside an update panel, when I click to execute and event, nothing happens.
<div style="margin: 0 auto; padding: 10px;">
<asp:UpdatePanel ID="panel" runat="server">
<ContentTemplate>
<div class="container-fluid p-3 mb5 bg-white rounded" id="card" style="margin: 0 auto; padding: 10px; border: 1px solid #f6f6f6;">
<div class="row" style="width: 100%; margin: 0 auto;">
<asp:Button ID="BtnSuspend" runat="server" CssClass="btn btn-success" Font-Size="10pt" Text="Suspend account" OnClick="Btnsuspend_Click" />
<asp:Button ID="LiftSuspend" runat="server" CssClass="btn btn-success" Font-Size="10pt" Text="Unblock account" OnClick="LiftSuspend_Click" />
</div>
<br />
<div>
<div class="input-group" style="width: auto; float: left; font-weight: 500; font-size: 10pt;">
<label>Total Users -</label> <asp:Label runat="server" ID="team" Text=""></asp:Label>
</div>
<div class="input-group" style="width: auto; float: right;">
<asp:TextBox ID="Searchbox" runat="server" placeholder="Search by Name or email" CssClass="form-control" Font-Size="10pt"></asp:TextBox>
<div class="input-group-append">
<button id="Searchbtn" runat="server" class="btn btn-primary" style="height: auto; background-color: #2c395c; border: 0.3px solid #d6d8d9;">
<i class="far fa-search" aria-hidden="true" style="font-size: 11pt; color: white;"></i>
</button>
</div>
</div>
</div>
<div class="grid-corner" style="width: 100%; background-color: white; font-size: 9pt; margin: 0 auto; padding: 5px;">
<asp:GridView ID="UsersGrid" runat="server" GridLines="None" AllowPaging="true" HeaderStyle-ForeColor="#224f6d" HeaderStyle-Font-Size="11pt" RowStyle-Font-Size="10pt" OnPageIndexChanging="OnPageIndexChanging"
AutoGenerateColumns="false" OnSelectedIndexChanged="OnSelectedIndexChanged" OnRowDataBound="OnRowDataBound" DataKeyNames="Name" PageSize="10" CssClass="table" Width="100%" HeaderStyle-HorizontalAlign="left" RowStyle-HorizontalAlign="Left">
<EmptyDataTemplate>
<div style="text-align: center; font-weight: 500; font-size: medium;">
<asp:Label ID="labelTemp" runat="server" Text="0 User"></asp:Label>
</div>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="Checksuspend" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Organization" HeaderStyle-Font-Bold="false" />
<asp:BoundField DataField="email" HeaderText="Email" ReadOnly="true" HeaderStyle-Font-Bold="false" />
<asp:BoundField DataField="CreatedDate" HeaderText="Joined" ReadOnly="true" HeaderStyle-Font-Bold="false" />
<asp:BoundField DataField="Suspend" HeaderText="Action" ReadOnly="true" HeaderStyle-Font-Bold="false" />
<asp:TemplateField HeaderText="Status" HeaderStyle-Font-Bold="false">
<ItemTemplate>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<div class="badge badge-pill badge-success" runat="server" id="active" style="font-weight: 500; font-size: 9pt;">Active</div>
<div class="badge badge-pill badge-info" runat="server" id="blocked" style="font-weight: 500; font-size: 9pt;">Suspended</div>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div style="float: right; font-size: 10pt; margin-right: 1%;">
Showing Page
<asp:Label ID="lblPageIndex" runat="server" Text="Label" />
of
<asp:Label ID="lblTotalPage" runat="server" />
(<asp:Label ID="lblTotal" runat="server" />
Records)
<div class="dvPager">
<asp:Repeater ID="rptPager" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>'
OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
<br />
<br />
<asp:HiddenField ID="hfcheck" runat="server" Value="0" />
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnSuspend" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LiftSuspend" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
protected void Btnsuspend_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in UsersGrid.Rows)
{
CheckBox Checksuspend = (CheckBox)row.FindControl("check");
if (Checksuspend.Checked)
{
string connectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("UPDATE Users SET Suspend=@Suspend WHERE Name=@Name", con))
{
cmd.Parameters.AddWithValue("@Suspend", "1");
cmd.Parameters.AddWithValue("@Name", row.Cells[1].Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
string message = "Account " + row.Cells[1].Text + " has been Susupended.";
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}
}
this.GetUserClientPage(1);
}
protected void LiftSuspend_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in UsersGrid.Rows)
{
CheckBox Checksuspend = (CheckBox)row.FindControl("check");
if (Checksuspend.Checked)
{
string connectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("UPDATE Users SET Suspend=@Suspend WHERE Name=@Name", con))
{
cmd.Parameters.AddWithValue("@Suspend", "0");
cmd.Parameters.AddWithValue("@Name", row.Cells[1].Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
string message = "Account " + row.Cells[1].Text + " has been unblocked.";
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}
}
this.GetUserClientPage(1);
}