asp.net c# button click refreshing whole page
I placed my repeater inside an update panel like this. Not sure why it refreshes the whole page when i click on these 2 buttons. Not sure why it does not work for these 2 buttons, it works for other buttons though, could it be because i added a new textbox on click of edit and the whole page refresh? As for the delete button, could it be because it couldn't find the position since its deleted? How do I solve this? Please help.
Home.aspx
<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater runat="server" ID="reptater">
<ItemTemplate>
<div>
<asp:LinkButton ID="editThreadBtn" CssClass="editThreadBtn" class="btn btn-default btn-sm" runat="server" OnClick="editThreadBtn_Click" Font-Size="Medium"><i class="glyphicon glyphicon-edit"></i></asp:LinkButton>
<asp:LinkButton ID="deleteThreadBtn" CssClass="deleteThreadBtn" class="btn btn-default btn-sm" runat="server" OnClick="deleteThreadBtn_Click" Font-Size="Medium"><i class="glyphicon glyphicon-trash"></i></asp:LinkButton>
</div>
<%-- show this textbox & button only if user click on edit thread --%>
<asp:Panel ID="editTread_pnl" class="input-group" runat="server" Visible="false">
<textarea id="editThreadTA" class="form-control" runat="server" style="font-size: 14px;"><%#Eval("Thread_Description") %></textarea>
<asp:Button ID="updateThreadBtn" runat="server" class="btn-info" Text="Update" OnClick="updateThreadBtn_Click" />
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Home.aspx.cs
protected void editThreadBtn_Click(object sender, EventArgs e)
{
LinkButton editThreadBtn_ = (sender as LinkButton);
// get repeater item reference
RepeaterItem item22 = editThreadBtn_.NamingContainer as RepeaterItem;
// get the repeater item index
int index = item22.ItemIndex;
// find the threadID label control
Label threadID_lbl = (Label)item22.FindControl("threadID_get");
int threadID_val = Convert.ToInt32(threadID_lbl.Text);
foreach (RepeaterItem i in reptater.Items)
{
Label Thread_IDs = (Label)i.FindControl("threadID_get");
int threadID_vals = Convert.ToInt32(Thread_IDs.Text);
if (threadID_val == threadID_vals)
{
Panel thread_editPanel = (Panel)i.FindControl("editTread_pnl");
thread_editPanel.Visible = true;
}
else
{
Panel thread_editPanel = (Panel)i.FindControl("editTread_pnl");
thread_editPanel.Visible = false;
}
}
}
protected void deleteThreadBtn_Click(object sender, EventArgs e)
{
LinkButton deleteThread_btn = (sender as LinkButton);
// get repeater item reference
RepeaterItem item25 = deleteThread_btn.NamingContainer as RepeaterItem;
// get the repeater item index
int index = item25.ItemIndex;
// find the threadID label control
Label threadID_lbl = (Label)item25.FindControl("threadID_get");
int threadID_val = Convert.ToInt32(threadID_lbl.Text);
SqlConnection con5 = new SqlConnection(constr);
con5.Open();
SqlCommand cmd5 = new SqlCommand("UPDATE Thread SET Delete_Status = 'Yes' where ThreadID = '" + threadID_val + "'", con5);
cmd5.ExecuteNonQuery();
con5.Close();
//Response.Redirect(Request.Url.AbsoluteUri);
showWholeRepeater();
}