Bootstrap accordion collapsed after postback

I have a bootstrap accordion inside a repeater and when I click on a control inside the body of the accordion that has autopostback to true, it postback correctly but the selected accordion pane is closing

      <asp:UpdatePanel ID="UpdatePanel8" runat="server">
                            <div class="accordion" id="acc<%# Eval("main_product_id") %>">

                                <asp:Repeater ID="Repeater2" runat="server" DataSourceID="odsMainProduct0" OnItemDataBound="Repeater2_ItemDataBound">
                                        <div class="card">
                                            <div class="card-header" id="h<%# Eval("product_id") %>" aria-expanded="false" data-toggle="collapse" data-target="#c<%# Eval("product_id") %>">
                                                <asp:HiddenField ID="hfProductId" runat="server" Value='<%# Eval("product_id") %>' />
                                                <asp:HiddenField ID="hfMainProductId" runat="server" Value='<%# Eval("main_product_id") %>' />

                                                <table style="width: 100%;">
                                                        <td style="width: 70%">
                                                            <asp:Label runat="server" Text='<%# Eval("name") %>' CssClass="linkbutton"></asp:Label>
                                                            <br />
                                                            <asp:Label runat="server" Text='<%# Eval("description") %>' Font-Size="8px" CssClass="linkbutton"></asp:Label>

                                                        <td style="width: 30%">

                                                            <asp:Button ID="btnHeaderSave" runat="server" ForeColor="White" Font-Bold="true" OnClick="btnHeaderSave_Click" BackColor="DarkRed" Font-Size="15px" Width="100px" Height="30px" Text="Button" />

                                            <div id="c<%# Eval("product_id") %>" class="collapse" aria-labelledby="h<%# Eval("product_id") %>" data-parent="#acc<%# Eval("main_product_id") %>">
                                                <div class="card-body">



What do I need to do to let the selected pane open after even a postback ?

I tried to do something with JavaScript code I found online but is not working

  <script type="text/javascript">
    $(function () {
        var paneName = $("[id*=PaneName]").val() != "" ? $("[id*=PaneName]").val() : "h128";

        //Remove the previous selected Pane.
        $("#accordion .in").removeClass("in");

        //Set the selected Pane.
        $("#" + paneName).collapse("show");

        //When Pane is clicked, save the ID to the Hidden Field.
        $(".card-header").click(function () {
            $("[id*=PaneName]").val($(this).attr("href").replace("#", ""));